Stephen George
Stephen George

Reputation: 27

How To Rotate My Character?

I am trying this method as an alternative to making 2 other animations. I tried to make the picture self-explanatory. All I am trying to do is to have a way to make my character rotate about 90 degrees to the right when the right key is pressed and rotate about 90 degrees to the left when the left key is pressed. I have tried Quaternion.RotateTowards and Quaternion.Slerp, but to no avail for me. Thank you :)

This should make it more clear

Upvotes: 0

Views: 1111

Answers (2)

Synthetic One
Synthetic One

Reputation: 405

I suppose something like this should work:

var direction = Mathf.Sign(Input.GetAxis("Horizontal")) * 90f;
transform.localRotation = Quaternion.Euler(0, direction, 0);

Upvotes: 0

Ozgur Yalcin
Ozgur Yalcin

Reputation: 55

Did you try the Transform.Rotate function with your character's transform object?

http://docs.unity3d.com/ScriptReference/Transform.Rotate.html

Upvotes: 1

Related Questions