Reputation: 13
If i'm rotating my player on the Y-Axis and move it like
transform.Translate(Vector3.forward * Time.deltaTime)
it will move along the Z-Axis of the character (as expected).
If I used CharacterController.Move it will always move in the same direction, independent from its rotation.
How can I make the player follow it's rotation?
Upvotes: 1
Views: 2082
Reputation: 653
The problem is that you are translating the character forward on a global level. This means forward will always be in the same direction. Instead, use transform.forward
. That way, you are translating the player on the forward vector on the player.
Another way to do it is using transform.rotation * Vector3.forward
. This will rotate the global forward by the rotation of the player, returning the same thing as transform.forward
.
Upvotes: 2