- Home /
How to make frame rate independent rotations?
So recently I've been implementing a pause function into my game and I've noticed that basically the only framerate independent function of my game is the rotation of my characters. This is how I am rotating my characters.
public void rotateMe (Vector3 lookDir, string playerName) {
Quaternion lookRot;
switch (playerName) {
case "P1":
lookDir.z *= -1;
lookRot = Quaternion.LookRotation(lookDir);
transform.rotation = lookRot;
break;
case "P2":
lookDir.x *= -1;
lookRot = Quaternion.LookRotation(lookDir);
transform.rotation = lookRot;
break;
}
}
So when I pause my game by setting the time scale this particular value doesn't pause. So the characters are still rotating around. Is there an easy way to express TIme.deltaTime to a quat? That seems to be giving me errors. Any help is most apprecaited.
huh? how do you call that routine? in Update or what? Do you know about FixedUpdate() ?
Yes I do. This particular component is called from a parent object container. It rotates the child object.
Answer by robertbu · Apr 14, 2013 at 02:44 PM
The easiest solution is to just check the time scale and return if you are paused. Add this to the top of the routine:
if (Time.timeScale < 0.01f) return;
Your answer
Follow this Question
Related Questions
Quaternion.Slerp rotation speed increases over script life. 1 Answer
Rotating around the Y axis then on Z axis makes my object rotate on the X axis 1 Answer
Transform a Vector by a Quaternion 1 Answer
Calculating Torque but cant add Quaternion 0 Answers
Lerp 180 degrees while holding B and lerp back 180 degrees when let go of B. 2 Answers