Waypoint angle
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 !!
If 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.
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.
Quote: Original post by Steadtler
If 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||)]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement