Hey guys,
I’m trying to use Qaternion.Slerp to rotate an object. It works fine, when I push a key my object rotates smoothly. However once I release the key, the object always turns back to start place, I just want it stops at where it should be after rotation rather than rotating back again, any suggestion would be appreciated.
public float RotationSpeed = 40.0f;
public float smooth = 2.0f;
void FixedUpdate()
{
float pitch = 0;
Quaternion targetRotation = Quaternion.identity;
pitch = Input.GetAxis ("Pitch") * RotationSpeed;
targetRotation = Quaternion.Euler(-pitch,0,0);
rigidbody.rotation = Quaternion.Slerp(rigidbody.rotation,targetRotation,Time.fixedDeltaTime*smooth);
}