Question by
macross_ · Jun 06, 2016 at 12:42 PM ·
rotationrigidbody2d
2d keep player upright
If i get hit from the side my player starts rotating and stops in a random position, but instead i want it to go back to it's initial position which is upright. How can i do something like that?
Here's an illustration: !
untitled-1.jpg
(45.4 kB)
Comment
Best Answer
Answer by Masterio · Jun 06, 2016 at 01:31 PM
You can save initial rotation in variable then use the Quaternion.Lerp function with current rotation and initial rotation as target rotation.
https://docs.unity3d.com/ScriptReference/Quaternion.Lerp.html
PS. You can try Slerp method too (read in google about diffrence).