I have a pause function in my game but every time i try to pause, unity freezes. I am not able to unpause or even close Unity without using the task manager.
if (Pause==false)
Time.timeScale=1;
else
Time.timeScale=0;
I have used Time.timeScale on earlier games without this problem.
Any ideas to what the problem might be?
Thx.
That is highly suspicious, I’ve used it many times as well.
Sounds like en endless loop or a divide by 0. Is it possible you have some logic elsewhere that would crap itself if Time.deltaTime were 0 or something?
uggh, that sounds like a pain to debug. Maybe you are hitting an infinite loop somewhere. Do you have any loops where Time.deltaTime is being used to increment the loop or set up a counter? Or some other place where a deltaTIme of 0 would cause problems?
Nope. As i said before, this is the only place i even use time… Time is not really my strong side and i actually still strugle with the use of Time.deltaTime
Assuming you don’t have access to the debugger, you best bet to figure out what is happening is to disable scripts to find out which one is breaking. If your really have no clue which one is breaking you’ll have to go with the classic, painful binary search technique:
Disable half your scripts and see if it still breaks. If it does, it’s probably in the enabled scripts. Split those in half, etc. Not fun.
But i cant possibly see what script i should be… of all the scripts in the game, i am pretty sure none deals with time in any way, exept from these four lines.
I had the same problem and it turned out to be the cloth physics component, as soon as I deleted it the problem went away. Maybe you got the same issue or some other rigidbody related problem:)