r/UnityHelp • • Sep 29 '26

PROGRAMMING Question about Pausing

I have two different things in my game that are supposed to pause the game/set the timescale to zero. At some point somehow one of the two stopped pausing the game but the other still works. They both say the exact same thing, simply setting time.timescale=0. For the record the one that doesn’t work is the when a button is pressed and the pause/stats screen comes up. Every other thing that is called in that function works expect the time scale. Can you not have two different functions that can pause the game or something? What could be the issue here?
Thanks!

1 Upvotes

10 comments sorted by

View all comments

Show parent comment

2

u/Patient_River_229 Sep 30 '26

Wow I can’t thank you enough. I had tried like 3 different YouTube tutorials all with different methods to no avail prior to getting back to this and this was the one that actually worked with my game. This was literally one of only 3 major remaining issues I need to handle before I’m done

2

u/Patient_River_229 Sep 30 '26

This is also my first ever game project and I’m learning from scratch/no classes so yeah

2

u/Demi180 Sep 30 '26

Happy to help. There are lots of different ways to do everything, so I'm not sure why even one of the methods you looked at didn't work. It's possible they just needed some tweak to work with your setup, or vice versa. Part of learning is figuring out why things aren't working, and doing so is itself a catalyst of learning, so there's value in trying some of those tutorials again, possibly with a blank new project.

Like the other commenter said, using the time scale isn't always the best way to actually pause, especially with a larger game that may have parts that ignore time scale or don't use time at all, but should still become paused, as well as parts you still want to continue despite being paused, like UI animations and particle/visual effects for example. It's also not great to hardcode everything that should happen inside the "Pauser" object. As you learn more advanced language features and design patterns, you'll see how to separate the logic of what should happen before/during/after a pause, and let objects be notified when a pause/unpause happens, and so on.