- Home /
reset rotaion
i'm having some trouble resetting my object back to its original position here's my code, it rotates fine
if (playerHealth < 50 && playerHealth > 0) {
rotateBar=0.02f * (rotateSpeed / (playerHealth / 100));
transform.Rotate (0, 0, rotateBar);
}
else {
transform.Rotate(Vector3.zero);
}
Answer by Rod-Green · Jan 10, 2012 at 04:28 PM
the last line should be
transform.rotation = Quaternion.identity;
This is because 'rotate' offsets the current rotation so if you had a rotation of 0,0,90 and you did rotate Vector3.zero you end up with 0,0,90 + 0,0,0 = 0,0,90
Answer by wallis2xk · Jan 10, 2012 at 05:19 PM
Transform.Rotate applies a rotation, it doesn't set it.
You can reset the world rotation with
transform.rotation = Quaternion.identity;
or you can just store your original rotation in a variable then apply it afterwards.
Answer by theUndeadEmo · Jan 17, 2012 at 07:01 PM
the above method works if the object is in world position however local position its doesn't work.
the object is attached to the main camera. i did fix the issue , but i used animations instead, so i had a few frames with the position reset.
Your answer
Follow this Question
Related Questions
Smooth reset rotation problem 1 Answer
Rotation Reset 0 Answers
Orbit around player, but allow re-centering of camera via button press? 2 Answers
Reseting armature's rotation in Unity 0 Answers