Advertisement Jump to content


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


Facing a target

This topic is 5480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I realize this has been asked before, but looking back through so many pages I could not find a solution that actually worked, and search is basically broken. Basically I need to orientate an object to face a point. I use 3D points but all I need is the Yaw really. I''ve used a variety of methods found in posts here, but basically, I get a vector that is (point-currentposition), and from there, I''ve done any number of different things, the last thing was to use atan2(x, z) more or less, and convert it to degrees, which is one of the things I found in a post. It obviously doesn''t work, so I''m looking for a relatively simple way of just getting a yaw/heading rotation with two points. Thanks in advance.

Share this post

Link to post
Share on other sites
The atan2(z,x) method should have worked if all you''re looking for is yaw. Like you said:

vecToPoint = point - currentPosition;

requiredYaw = radToDeg(atan2(vecToPoint.z, vecToPoint.x));

If you''re using right handed systems, the requiredYaw above will be a counter-clockwise rotation around the Y axis, where yaw=0 will fall along the z axis.

Share this post

Link to post
Share on other sites
Nevermind, I found the problem. My camera ends up storing the Z oddly, and as a result I had to flip the sign on the starting position, and now it faces right at the camera no matter where it goes.

Thanks for the help!

[edited by - Cor on January 23, 2004 4:28:04 AM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!