Time.deltaTime issue

I meant Time.timeScale in title --sorry

OK you can see the below script and this has worked in the past to pause a game. Since I have upgraded to 3.4 it seems Time.timeScale only effects the script that you change it in. For example if I print(Time.timeScale) from this script I get 0 as expected when I hit pause button. However if I print print(Time.timeScale) from any other script I get 1 wether I hit pause button or not – am I missing something? Shouldn’t Time.timeScale effect all active scripts?

#pragma strict
var paused : boolean = false;
var pauseToggle : int;       
    
    
    
  function Awake(){
  	
  	useGUILayout = false;
  	
  }  
    
    
       
 
function Update () {


  
     if(pauseToggle == 1){

       if(!paused){
      Time.timeScale = 0;
      paused=true;

       }
     }
        else{
 
         Time.timeScale = 1;

         paused=false;

      }

}





function pauseGame1(){
	if (pauseToggle != 1){
			
			pauseToggle = 1;
    }
	else{
		pauseToggle = 0;
		
		}
	
}

Time.timeScale is project-wide, not per-script. Maybe your debug messages are misleading, such as having “collapse” on in the console.

–Eric

Well why is it not stopping everything then? it always has in the past now it isn’t since the upgrade how do you explain this?

ok I just put Time.timescale=0; in one of the updates on another script – no conditions – everything keeps right on moving.

The interesting thing is if I add it to a prefab then instantiate with Time.timeScale=0; in Update or Start it stops everything in their tracks.

I think this might be a bug or something. I also added an empty game object with Time.timeScale=0; in Update and Start and nothing stops.

I can’t tell from the code you posted. Time.timeScale = 0 works the same as always here.

–Eric

Ok well I deleted my game objects and reattached everything – it is now working. I have no idea what happened but thanks for the replies.

I likely did something wrong or missed some detail.

Or some script was out of date and messed it. Doing a reimport on the script folders you have in your project can normally resolve such things :slight_smile: