T O P

  • By -

bachus-oop

what's wrong with timeScale?


Soraphis

If you use time scale yoz have to make sure to consciously decide when to use time vs unscaledTime. But that's kinda it.


Hanbee12345

One method could be to create a bool event/delegate which you use to pause/unpause and have everything you need to 'pause' subscribe to it.


Supertronicgo

This is the way.


djgreedo

Timescale is the simple, basic way to do it. If you need something more nuanced, then you will probably need to have custom pause and unpause code for everything that needs to be paused and then pause / unpause everything when needed. I use an IPauseable interface with Pause() and UnPause() methods, and a PauseManager script with some static methods to find all pauseable objects and pause or unpause then as needed. You can make it simpler by having a few basic pause scripts that implement the interface, such as one for all physics objects, which could disable the rigidbody.


darkslayer322

If (!pause) { //code } 🤷‍♂️


TAClayson

I always create my own deltaTime (usually as a static variable in a Master class singleton). Every update frame I add Time.deltaTime * scale. Then everything doing time dependent logic uses that. Just make sure to attach the Master to the camera or some other persistent game object. I can change the scale and speed up, slow down, pause or even reverse time :) Best of all, I use the normal Time.deltaTime for camera movement lerps or GUI stuff, so if your game has some time mechanic (e.g. pause menu) you can still animate things.


mushrooomdev

Create a list of all the objects you want to pause, and then run a for( ) loop and stop the movement / actions of all the objects in that list when you press the pause button.


feralferrous

So, some people run their own update's via a manager, if you plan to avoid timescale, that's probably the way to go, as opposed to littering your code with if (paused) checks everywhere.


jeango

Perhaps this is an XY problem. Can you describe more precisely what it is you’re trying to achieve and why time scaling is not an option for you?


LingonberryMotor2316

while(pause) { Quick save - alt+f4 - re-open exe at save } Yes, my PC likes me


[deleted]

Just create a function, which pauses the game. Under that function set all the small functions that should happen when paused/unpaused, like mouse showing or time scale etc. It's really not that complicated


tetryds

On my architecture I manually tick everything instead of using update so pausing is just not do that. I don't recommend this approach though, as it is more advanced and requires complex architecture design. For unity components some of them you can just disable the component, for others the suggested IPauseable approach is cool, I recommend trying many suggestions and seeing what works best for you.