• Advertisement
Sign in to follow this  

look at

This topic is 4649 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