How to Quaternion Slerp back to Original Position but Keep Current Heading?
Hi guys,
I'm using this code:
transform.rotation = Quaternion.Slerp(transform.rotation, originalRotationValue, Time.time * rotationResetSpeed);
which works great.
However, originalRotationValue returns back to 0, which makes sense as in Start() we have:
originalRotationValue = transform.rotation;
The problem is I need to keep the originalRotationValue.y where it's currently at.
Not rotate back to 0.
Can you please help?
Thanks!
Do you want the Y value to be the same at all times? Could you simply add a statement after your slerp that sets transform.rotation.y to a fixed value?
No.
The Y value needs to be whatever the direction the character is facing after the joystick has been released.
So if we turn left facing 270 degrees, I still need to be facing 270.
The slerp comes in if I pitch or roll the game object forward or back.
The Y axis needs to stay the same.
This throws an error but should elaborate on what we're trying to do:
transform.rotation = Quaternion.Slerp(transform.rotation.x, originalRotationValue, Time.time * rotationResetSpeed);
transform.rotation = Quaternion.Slerp(transform.rotation.z, originalRotationValue, Time.time * rotationResetSpeed);
but keepp transform.rotation.y value the same.