Need help rotating

Started by
2 comments, last by Andreas Persson 18 years, 8 months ago
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
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
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
Yes I was thinking along that line my self but couldn´t formulate it. Thanks!
Casual game dev www.apgames.se

This topic is closed to new replies.

Advertisement