Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Time.timeScale changes by itself

Discussion in 'Scripting' started by mikie1002, Nov 15, 2019.

  1. mikie1002

    mikie1002

    Joined:
    Apr 22, 2018
    Posts:
    7
    I used Time.timeScale = 0 to simply pause the game and confronted with strange behavior. First game freezes as it should be, but after several seconds it starts play again all by itself, as if timeScale is back at 1. Seems it started when I added some animations to my game objects. I don't understand what's happening. I didn't change anything in code, just added animations in editor. Anyone has an idea what it might be and how to fix it?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    Some other script must be changing it, or possibly your script is behaving in a way you didn't expect. Search for "timeScale" in your entire project folder and see if something else is using it.

    If not that, then wherever you're setting it back to 1, try adding a Debug.Log to see if that line is being executed.
     
    Joe-Censored likes this.