Skip to main content
gamedev.net
🔒 Locked

Need help rotating

Started by Andreas Persson Aug 10, 2005 at 11:41 AM 2 replies 700+ views
Original Post
Andreas Persson
Andreas Persson
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.
Casual game dev www.apgames.se
neneboricua19
neneboricua19
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
jujumbura
jujumbura
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
Andreas Persson
Andreas Persson
Yes I was thinking along that line my self but couldn´t formulate it. Thanks!
Casual game dev www.apgames.se

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.