Jump to content
  • Advertisement
Sign in to follow this  
Chr

look at

This topic is 4886 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've object A1 and object A2. I can cotrol object A1, let's say with the keyboard (w,s,a,d) Now i want that object A2 looks ever to object A1, how can I implement this?

Share this post


Link to post
Share on other sites
Advertisement
get delta x and delta z values of A1 and A2 positions. divide them then use arctangent function to calculate the angle.
it should be something like this:

delta_x = A1.x - A2.x;
delta_y = A1.y - A2.y;

if(delta_x != delta_y)
{
if((delta_x > 0 )
my.pan = atan(delta_y/delta_x) - 90;
else
my.pan = atan(delta_y/delta_x) + 90;
}
as you see, this only works with Z axis. bur you can make for x and y like that if necesserry. you may have a look math forum for more advenced solutions..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!