Time.timeScale?

Posts 12 of 2 · Page 1 of 1
Time.timeScale?
Code:
#pragma strict

static var timeScale : float;


function Start () {
	if(Input.GetKey(KeyCode.P)) {
		if(Time.timeScale == 1.0)
			Time.timeScale = 0.0;
			
		else
		Time.timeScale = 1.0;
			Time.fixedDeltaTime = 0.02 * Time.timeScale;
	}
	
	if(Input.GetKey(KeyCode.P)) {
		if(Time.timeScale <= 1.0)
			Time.timeScale = 1.0;
			
			else
			Time.timeScale = 0.0;
				Time.fixedDeltaTime = 0.02 * Time.timeScale;
	}
}


function Update () {


	
}
It is supposed to act as a psuedo-pause function for a game I'm making in Unity. But when I press "P", nothing happens. Why?
trace it with print inside start and inside P if..
it will help you to trace what wrong with you code..

but i think start is run just once?..
like a first initialize, maybe u need to put that code on update function..
basicly i have play with unity but just for a moment..
if its work like XNA, its have 3 phase. first is initialize, update, and destroy..
Posts 12 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?