# HELP!! Angle Between 2 Character

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

## Recommended Posts

Hi, Needed help here!!! How can i find a angle between 2 character in a 3d plane so that 1 of the character will always face the 1 moving around him??.. Here is the formula i've tried, i'm not sure if it is because of the moving character's x and z axis is negative. btw: i'm using dot product float ax = 10; //vector 1 float az = 0; //vector 2
• 104
• Your algorithm probably fails in case the angle is greater than 90°.
Use float angle = atan2(bz, bx) to get a 4 quadrants angle.

To convert into degrees you don't have to multiply by 2 (my advice is to use radians and never convert to degrees):
float roty2 = angle * 180/pi; //Final Angle in Degree

If (ax, az) is constant (10, 0) (why not (1, 0)?), roty2 is not the angle between the facing of player and AI, but the absolute orientation player must have to face AI.
You have to update player_orientation = roty2, not player_orientation += roty2 (just to be sure ;).

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633678
• Total Posts
3013286
×