# look at

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

## 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 on other sites
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..

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 12
• 15
• 11
• 12
• ### Forum Statistics

• Total Topics
634153
• Total Posts
3015844
×