Why does my rotating platform not pause when I pause the game?

I have been learning JS and really getting into it. I mocked up a level and began building it. I added a rotating cylinder that has a series of platforms that rotate counter to that of the cylinder.

Looks like a ferris wheel. The cylinder moves one way while the platforms move the other. This gives a nice effect of seeming like they are hinged to the cylinder.

here is where the problem comes in. I added a pause menu. When I pause the game, everything stops as expected, sans the items rotating.

Not really sure why this is happening but here is some code if anyone wants to take a crack at it.

// code for Platform.js

var rotatePlatformCW : boolean = false;
var rotatePlatformCCW : boolean = false;
var speed : int = 5;

function Update(){
	if (rotatePlatformCW == true){
		transform.Rotate(0, -.35, 0 * Time.deltaTime);
	else if (rotatePlatformCCW == true){
		transform.Rotate(0, .35, 0 * Time.deltaTime);

// Code for Pause.js

var paused : boolean = false;
var pauseIcon : Texture;
var pausedTime : float = 0.000001;
var unpausedTime : float = 1.0;

function OnGUI () {
	if (GUI.Button (Rect (Screen.width - 100,Screen.height - 50,100,50), pauseIcon)) {
		if (paused == false){
			paused = true;
			Time.timeScale = pausedTime;
			else if (paused == true){
				paused = false;
				Time.timeScale =unpausedTime; 
		print ("The Game is Paused");

Any help is greatly appreciated!

I see two snags.

First, it looks like you’re setting Time.timeScale to a very small number, but not zero. Maybe there’s a reason for that, but it seems a little strange to me. Super slow motion? Not necessarily a problem, but I figured I’d point it out.

Second, you probably realize that your behavior scripts will still get Update() calls while time is “frozen” – the only inherent difference is that time steps will be zero (or, in your case, incredibly small). With that in mind, let’s take a look at your rotation code:

transform.Rotate(0, -.35, 0 * Time.deltaTime);

You probably want to multiply that second parameter, rather than the third one? Multiplying by zero will always produce zero. Meanwhile, the second number is not being scaled by your frame time.

If you want, there is an overload for transform.Rotate() which takes a vector; if you use that call, you can scale all three axes with one multiply operation. If you’re pretty sure you only want to rotate on the one axis, this is sort of a moot point, of course. :slight_smile: