Jump to content
  • Advertisement
Sign in to follow this  
jolyqr

Waypoint angle

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

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 this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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||)]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!