Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


bots direction

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

Hi Currently, my bots are correctly navigating between waypoints as they should. Now the problem i have is making them facing the direction they are walking. I already get the angle that they must rotate.., please, look at this: P3..........P2...........P4 ............P1 Ok.., my bit is in waypoint P1, and going to P2. I have 3 vectors here.. P1-P2 / P2-P3 / P2-P4 The angle between P1-P2 and P2-P3 is 90 degrees, as it is between P1-P2 and P2-P4.,.., so far so good. Now, my problem is findind the direction of rotation., if my bot is going to P3 i must rotate -90, if going to P4 i must rotate 90...., Anyone knows a way to find out the sign of rotation ? thanks.., Bruno

Share this post

Link to post
Share on other sites
To get from an x and y vector to an angle, use the arctangent function. atan2() is probably your best bet.

Share this post

Link to post
Share on other sites
If you define your vectors as:
v = line(P1,P2)
w1 = line(P2,P3)
w2 = line(P2,P4)

then the following holds

p = -q

p = v x w1
q = v x w2

the ''x'' means vector cross product.

You can use this sign difference to distinguish between w1 and w2 and hence determine a +1 or -1 multiplier to the 90 degrees angle to get your bot to turn in the correct direction.



Share this post

Link to post
Share on other sites

  • 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!