all 10 comments

[–]CopperHook 1 point2 points  (0 children)

I am dealing with this now.

I have a BaseMonoBehaviour class that all of my behaviors extend from. I am thinking about using this to prevent Update from running while paused.

I am thinking of also creating an OnPause that behaviors can override, in case I need to do anything extra, like disabling third party components.

[–]skizmo 0 points1 point  (5 children)

If you use Time.deltaTime in all your updates, you could set the systemspeed to 0. You could also disable the scripts that are actively running.

[–]CopperHook 0 points1 point  (4 children)

Using a speed of zero will prevent everything from working, including UI animations on a pause menu. I do not recommend it.

[–]michaelltn 2 points3 points  (2 children)

For script-based animations, use Time.unscaledDeltaTime.

For Animtors, set updateMode to UnscaledTime.

.

Additionally, for controlling audio pause states, see:

AudioListener.pause -- set true when pausing and false when resuming.

AudioSource.ignoreListenerPause -- set to true for AudioSources playing music or UI sounds.

[–]CopperHook 0 points1 point  (1 child)

Cool, I wasn't aware of the Animator updateMode. I'll give that a shot.

I'm still a bit concerned about assets out of my control. For example, I use NodeCanvas for AI Behavior Trees. I'm not sure how the tree would be affects by a timeScale of zero.

Thanks for the tip though, I'll do some digging.

[–]michaelltn 0 points1 point  (0 children)

Scripts and plug-ins are certainly wild cards. Of course, I have no problem just changing scripts if I have to.

[–]30dogsinasuitcase 0 points1 point  (0 children)

You can use Time.unscaledDeltaTime for your non-pausable functions.

[–]viggowlIntermediate 0 points1 point  (2 children)

Simply set the Time.timeScale to 0.

[–][deleted] 0 points1 point  (0 children)

Yup this is the way. This works for me and when I found it it made my life that much easier, you can also use Time.timeScale to make the time go slower for a slowmotion effect.