i have a sliding in pause Menu. I click the options Button and then i call
public void PauseGame()
Time.timeScale = 0;
Problem is, it wont slide in because the animation is instandly stopped from that.
What’s best way to fix this? A Coroutine?
Thanks in advance.
Coroutines stop being invoked if timeScale is zero.
If you’re animating with an Animator (not an Animation component), you can set the Animator to use Unscaled Time as it’s update mode. That’ll make it not care about the timeScale:
Animator myAnimator = GetComponent<Animator>();
myAnimator.updateMode = AnimatorUpdateMode.UnscaledTime;
That’s very ideal for things like pause menus. If you’re using an Animation component, well, now’s the time to read up on Animators.
To fix this, i use the eventsystem inside the animation window, so once the animation has ended, i call the scriptfunction i was writing in the first post. This will end the animation and will pause all after this.
I just needed to add the script onto the object where the animation on.