Archived

This topic is now archived and is closed to further replies.

jonbell

Direction to an object

Recommended Posts

Given a 3D positional vector p1 which also has an accompanying directional vector v1, how can i make p1''s direction vector point at any arbitary point? To put this in more of a context p1 is the position of an enemy in a 3d landscape, the enemy has a position and a ''look'' vector. I want to set that look vector to point to any point i pass the function.

Share this post


Link to post
Share on other sites
guy.directionVector = thingToLookAt.position - guy.position;
guy.directionVector.Normalize();

Share this post


Link to post
Share on other sites
I cannot believe its that simple, i''ve been calculating angles between axes and all friggin sorts. Thx Man

Share this post


Link to post
Share on other sites
well, it depends on how your direction vector is like. if it is just a x,y,z pointing in the direction, then it should work... unless i incidently swapped thingToLookAt and guy positions

Share this post


Link to post
Share on other sites