Jump to content
  • Advertisement
Sign in to follow this  

DotP for Rotation Direction probem

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

I have an AI character who wants to move to a position. He needs to rotate to face the position to walk there.

I'm using the dot product between the AI char's current right direction and a vector from the AI char to the target to determine if it should turn left or right.

Vec3 oPosRel = this.Pos - Target.Pos;

if (oDirection_Right.Dot(oPosRel) < 0.0f)

This works 99% of the time.

Though if suddenly the ai needs to move in the opposite direction it gets stuck rotating in both directions left-right-left-right etc until finally, randomly it stops and rotates properly.

It seems to be relative to the size of "a_fDeltaTime" also. If I have a smooth 60 fps it never happens but if I zoom out dropping to 17 fps it happens every 1/20 direction changes or so.

Am I doing something wrong or should this work?

EDIT: Nvm. Solved >< Edited by reaperrar

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!