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.

1 Answer

1

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;