# Waypoint angle

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

## Recommended Posts

basically i have a NPC which have to move according some waypoints. before moving to a waypoint, i want this NPC to look at the waypoint direction (like a human would do). i know the angle where the NPC is looking, i know the NPC position, i know the waypoint position as well. Now i'm looking for the way to get the waypoint angle... cheers !!

##### Share on other sites

WaypointPosition - NPCPosition will give you a vector from the NPC to the way point.

Now when you say you know the "angle" the NPC is looking... angle from where???

If you know the vector pointing toward the NPC looking direction, you can get the angle between that and the vector pointing toward the waypoint by doing the arccos of the normalised dotproduct.

A tip: work with vectors, not angles.

##### Share on other sites
Quote:
 Original post by SteadtlerIf I understand your question...WaypointPosition - NPCPosition will give you a vector from the NPC to the way point.Now when you say you know the "angle" the NPC is looking... angle from where???If you know the vector pointing toward the NPC looking direction, you can get the angle between that and the vector pointing toward the waypoint by doing the arccos of the normalised dotproduct.A tip: work with vectors, not angles.

if i have well understand, i should use the following formula:

where v and w are two vectors, tetha the angle between them.

v.w=||v||||w||cos(tetha)

tetha=arccos[(v.w)/(||v||||w||)]

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009399
• ### Who's Online (See full list)

There are no registered users currently online

×