- Home /
Rotate back to original x rotation
Hello! I have a first person controller that tumbles while freefalling then when it is a certain distance above the ground it rotates back to its original(standing) rotation. The problem I have is that it rotates it back to its x y and z rotations, where I only want it to be back at its original x rotation (it can be facing any direction, think like a cat landing on its feet). The code I have is this:
public Quaternion origRot;
........
origRot = transform.rotation;
........
transform.rotation = Quaternion.Lerp(transform.rotation,origRot,1.0f * Time.deltaTime);
The periods are filler because I took out a lot of unrelated code, but what can I do to make this work correctly? Thank you ahead of time!
Answer by Swaggre · May 06, 2014 at 08:30 AM
Okay, last line should be:
transform.rotation = Mathf.Lerp(transform.rotation.x,origRot.x,1.0f * Time.deltaTime);
Your answer
![](https://koobas.hobune.stream/wayback/20220613144253im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why is this rotation acting odd? 0 Answers
Connecting transform with Vector3 4 Answers
Quaternions acting up 1 Answer
Rotating an Object to its Original Angles after certain distance from ground 1 Answer