Jump to content
  • Advertisement
Sign in to follow this  
Andreas Persson

Need help rotating

This topic is 4846 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 I am making a space shooter and need my enemies to turn towards the player. How do I do that I know how to get the angle and to rotate but cant figure out how to stop when facing the player.

Share this post


Link to post
Share on other sites
Advertisement
Stop rotating when the angle between the enemy craft and the player gets close to zero. One way to do this is to interpolate your rotation over time.

neneboricua

Share this post


Link to post
Share on other sites
I'd try doing a comparison of two vectors: the direction that the enemy ship is currently facing, and the direction from the enemy ship to the player. ( ie: initial, final ).

As you rotate towards final, do some sort of comparison that seems appropriate.

if ( (current vieWVectorDimensions - final ViewVectorDimensions) < acceptableDimensionDifference )
{
stopTurning
}
else
{
recalculate turning axis, turn more, loop again
}

Is that reasonable?

Mike

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!