Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Time.TimeScale = 0f stopped working to pause game. It somehow sets back to 1f, why? help please

Discussion in 'Scripting' started by HolyNova, May 31, 2015.

  1. HolyNova

    HolyNova

    Joined:
    May 19, 2015
    Posts:
    13
    Hello there, yesterday I was implementing a pause in my game, I followed some tutorial and everything was working fine. Game was pause when I hit escape and unpaused when I hit resume in my pause menu. Today it magically stopped working. I tried to debug it, but only thing I got is, that it somehow sets back to 1 after I set it to 0. Why? Can anybody please help me to solve this as I really want to pause my game? I attached link to my pausegame script. I really wonder what I did, that it stopped working. Can't figure it out. Thank you all for any help. I appreciate it.

    http://pastebin.com/1ZSECNmS
     
  2. HolyNova

    HolyNova

    Joined:
    May 19, 2015
    Posts:
    13
    Nevermind. Got it working. Hint for future developers. Take care, where else you play with Time.TimeScale values. I had another script for game over menu, where I had an else statement in Update() method, which was setting Time.TimeScale back to 1. Fixed!