So, I have object, and then player doesn’t do anything, it spins in place: gameObject.transform.Rotate(rotationSpeed * Time.deltaTime, rotationSpeed * Time.deltaTime, rotationSpeed * Time.deltaTime);
. And I want when player touches object, it would get back to its start rotation form, using: gameObject.transform.Rotate(0, 0, 0);
, but the thing is, that doesn’t work. Gameobject is still rotated. ( I also made, then player touches object, it will not rotate, that doesn’t work) Does anybody know how to fix that?
Essentially, gameObject.transform.Rotate(0, 0, 0) tells the object to rotate by 0 degrees, so it won’t rotate at all. What you want is to lerp the rotation back to 0, like this:
float lerpSpeed = 0.125; // A random number
transform.rotation = Quaternion.lerp(transform.rotation, Quaternion.Euler(Vector3.zero), lerpSpeed);