Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Problem with a pause menu with animations

Discussion in 'Editor & General Support' started by SkrenZz, Jun 18, 2020.

  1. SkrenZz

    SkrenZz

    Joined:
    Apr 11, 2020
    Posts:
    26
    [EDIT: The issue is resolved, the solution was changing the "Update Mode" field of the animator component to "Unscaled Time" instead of "Normal".]

    Hello there,

    First of all, I hope I am posting this thread to the relevant forum. I thought about posting it to the animations forum but my issue is not specifically about the animations themselves.

    I have created a pause menu to my game which exists in a separate scene that is being loaded on Awake to the game scene using LoadSceneMode.Additive.
    In my pause menu I have four buttons, that I've added a simple animation to them which causes them to become bigger and then back to their normal size when a button is selected. The problem is that animation is getting stuck on the first frame, and after checking what causes this issue, I found out that it happens because I am setting Time.timeScale to 0 when pausing (when I commented this line the animations worked properly, but obviously the game was no longer paused).

    Is there a way to change Time.timeScale only on my game scene while not affecting additive scenes, so it actually pauses without preventing the animations in other scenes from playing (which would be ideal if this solution is possible)? If not, what else could I possibly do to solve this issue while making sure the game is indeed paused?

    Many thanks in advance to anyone who'll try to help, and have a great day!
     
    Last edited: Jun 18, 2020
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,932
    How are you doing your animation? If it's a custom script you wrote, just use Time.unscaledTime and Time.unscaledDeltaTime in that script.
     
  3. SkrenZz

    SkrenZz

    Joined:
    Apr 11, 2020
    Posts:
    26
    I'm using the animator. I've just read an article about pausing a game in unity and managed to fix my problem, the solution was changing the "Update Mode" field of the animator component to "Unscaled Time" instead of "Normal".

    Thanks a lot PraetorBlue!
     
    Last edited: Jun 18, 2020
    sclt5741 and PraetorBlue like this.
  4. OmarStudios

    OmarStudios

    Joined:
    Apr 14, 2021
    Posts:
    2
    I didn't get that , Do you mean instead of using time.timeScale = 0 To stop the game i should use time.UnscaledTime = 0 ?
     
  5. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,932
    No.

    Time.unscaledTime is a replacement for Time.time.

    Time.unscaledDeltaTime is a replacement for Time.deltaTime.