Rotation

2 replies [Last post]
Offline
Joined: 12/10/2010

 In ideal situation, I want my main Character to first rotate to face the direction and then go there and I want the smooth turning to that direction no matter which direction Character is currently facing (left/right/north/south)
 
I am trying to come up with some kind of formula to calculate which way to turn left or right ... lets say I am facing left and I want to turn north ... i turn right 90 degrees and not 270 to degrees to the left etc ... 

Offline
Joined: 12/13/2010
Since this question has 2

Since this question has 2 parts, I'll answer them separately.

First question: How to make the rotation smooth?

You can do this using a similar strategy to the walking smoothly.  Create a field in your creature to hold the destination angle.  As long as the current rotateY is NOT the destination angle, modify rotateY by either adding or subtracting from it.

Second question: How to find the smallest rotatation?

A simple strategy is to similar subtract the destination angle from the start angle, and then compare the values to determine which way to turn (either add or subtract).

 

Offline
Joined: 01/06/2011
I'm going to recommend the

I'm going to recommend the same series of articles that I recommended in the other thread since this sort of thing also applies:
http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1/