Some kind of SetForwardVector
by Andrei O. Victor · in Technical Issues · 07/11/2007 (6:30 pm) · 2 replies
Hello everyone.
I wish you could help me in figuring the right math for this (or perhaps another thing besides math).
I have a vector that i desire where my player will face forward. Now, I'm having trouble making my player to actually face that direction.
Here's my take so far:
It simply doesn't do the job? What's wrong?
I wish you could help me in figuring the right math for this (or perhaps another thing besides math).
I have a vector that i desire where my player will face forward. Now, I'm having trouble making my player to actually face that direction.
Here's my take so far:
function TargetObjects::FaceTarget( %this, %obj )
{
%angle = mAcos( VectorDot(
VectorNormalize( VectorSub( nameToID( "cam_PlayerView" ).getPosition(),
%obj.getPosition() ) ),
VectorNormalize( %obj.getForwardVector() ) ) );
error("Obj(" @ %obj.getId() @ "):" SPC mDegToRad( %angle) );
%pos = %obj.getPosition();
//%rot = getWords( %obj.getTransform(), 3 );
%rot = "0 0 1" SPC mDegToRad( %angle );
%obj.setTransform( %pos SPC %rot );
}It simply doesn't do the job? What's wrong?
#2
so your call to mDegToRad() ain't needed.
a good general approach to debugging things like this is to bust it up into component steps who's correctness you can verify.
ie, your huge mAcos line could be busted up into a bunch of sub operations, the results of each of which you could echo to the console.
07/11/2007 (7:32 pm)
Oh but one thing that stands out is that i'm pretty sure mAcos returns radians, not degrees,so your call to mDegToRad() ain't needed.
a good general approach to debugging things like this is to bust it up into component steps who's correctness you can verify.
ie, your huge mAcos line could be busted up into a bunch of sub operations, the results of each of which you could echo to the console.
Associate Orion Elenzil
Real Life Plus