What if you use Unity Phisics + have some TweenAnimations in Game And when your game pause you need to Stop Update it??? State machine doesn't work here So I think the video is misleading.
Timescale is easier because there is less to learn and less to type. But it's also the lazy way to do it. I have often had trouble with Timescale messing with my animations or my UI, so this might be better in those cases. Nice to know there is another option. But of course Unity and C# always have multiple ways of doing things, so it entirely depends on your current code and how your project is put together.
I guess it depends what you consider as pause, for example I want to "freeze" the whole world, so animations, physics etc should stop while in pause, so setting TimeScale to 0 makes more sense in that case, otherwise I would have to manually pause all animators etc. For the few animations that should still play (for example pause menu) I can just change the animator to unscaled time so they will still work just like before.
Yeah, I get the idea of this video, but to hook up everything in your code base to this event to respond properly to a pause sounds like a nightmare. For the few things I want to not be completely paused or have some special pause behavior I'll handle those exceptions accordingly. Also, not that you have to our should listen to Unity, but they recommend pausing with time scale.
@@Feral_Pug_Codes I was being a little facetious. I can't believe that this function isn't in Unity by default. Similar story with timers. I used to think Unity was the best. >.>
@@poseeley It just depends on what TYPE of "pause" you want. Godot has a built in "pause" function where you can pause the whole thing, or leave things active. Unity has the same thing....which is Timescale. Some devs want the day and night, NPCs to pause, but crafting stations to continue. Some want only player to pause. Various other combos. Thats what Timescales can control. Plus you can have an interface that will allow to speed up or slow down time AND pause. Can do the same in Godot, but some scenarios can take alot more code and workarounds. Unreal gives a ton of control too.
>Artificially sped up audio to sound like you have confidence >Engine has built-in ways to arbitrarily speed up/slow down the game including full stop >It also has built-in solution for the exact same problem shown in the video by just using unscaled time >You can still make pause event that some script can subscribe(like audio sources that don't automatically "pause" from timescale) that can have special logic on pause >Have a public get private set property AND have a set method >Every single script that should pause is the exception and not the other way around which makes the entire codebase very bloated Yeah, no. I agree that just simply setting timescale to 0 is not enough, this is just overcomplicating things. Novice developers are gonna watch this and make their game too complicated that they can't work on it anymore. Don't reinvent the wheels. Make them better. EDIT : also, "GameState" enum is not needed unless you are planning to add multiple pause state which is pretty rare. A simple bool would be more than enough. GameStateChangeHandler delegate is not needed and you can just use Action to make your life a lot easier. Singletons that instances itself can generally be replaced with static classes that do much of the same thing. It's easier to write GameStateManager.Pause() than GameStateManager.Instance.SetState(GameState.Paused) which is a lot longer with not much more context.
Yep as per usual this dude learned this last week and is posting it in a short format that's taking off because of Tarodev and others. This tutorial overcomplicates simple pausing by like 4 completely unnecesary states. Pausing one way or the other is NOT wrong. There are situations for everything.
But it begins to push game developers pass the basic. What he's teaching isn't wrong, just another method to do the same thing, except his allows for more granular control.
Okay, but this requires you to add this to every single object that could be effected by a pause, and if you miss anything it would put holes int he game that could seriously break things. Alternatively you could just use unscaled time to animate your UI.
@@mikkelens It sounds fun to add this into everything... You can use it if you want, but it's just sounds like multiple hours of extra work for the same effect which you can get via 2 lines of code...
@@mikkelens Quite frankly, no, I wouldn't rather have that. Especially as my game scales more and more and grows bigger. Every new element I introduce into my game is another thing that potentially could screw up when I try to pause. But with adjusting the time scale, literally the only thing I have to fix is the pause menu itself. No matter how much bigger my game grows, I will never need anything more to be active when the game is paused.
This is actually how it should be done in game framework, everywhere. Which means all your framework objects should subscribe to game events throughout inheritance (automatically). Otherwise you will end up with many objects cheking for game states or worse, trying to setup timescale at the same time. Unity encourage very bad coding practices.
@@tatoforever Honestly, that really comes down to the structure you need for your project. I certainly respect the idea of setting up pause actions through inheritance, and that would be very easy to do in Unreal where you have access to these base classes. But with Unity's structure you can't apply that code to the base monobehavior, so you have to ask: Am I more likely to create a script and forget to have it inherit from a pausable class, or am I more likely to have some other random script adjust the time scale. I'm sure if I was doing a lot of ramping effects in my game it may be more reasonable to incorporate a pause function into some base classes. But if that's not a thing, then relying on time scale to control pausing is safer.
As for me, much easier and readable to use timescale and unscale properties where you need, rather make every single timer and movement script depends on pause flag. There is not so many situations, where you really need to overcomplicate pause in this way
I would still recommend doing the actual pausing/unpausing itself in your game manager rather than setting timescale manually in your scripts, because that way you can centrally manage it. This way, if you ever need to change the timescale for some other reason, such as bullet time, you can pause/unpause the game while maintaining the correct timescale (unpausing back to bullet time), as well as managing timescale in other ways.
Hm, would make far more sense to pack all of this into a GameStateBehaviour script, and just inherit from that on any classes that need to be paused - otherwise you're bloating your code by adding nearly identical boiler-plate pausing code to tons of different scripts. Also, if all pause-able classes inherit from the same base, the reused code only needs to be changed in one place, for any unforeseen future updates farther down the line. I would make the private methods OnGameStateChange(), Awake(), and OnDestroy() into protected virtual methods: they can now be easily overridden if the code needs to execute differently on one script, while all still using the SAME pipeline for pausing and resuming.
What he’s essentially using is called “the observer pattern”. But this does complicate things somewhat. Like for myself, I’m making a 3D platformer. If my character jumps and I want to pause using this method, I then need to make sure everything in its script is canceled, especially making sure that gravity is not longer applied or the character will still fall. His animations will also still play unless I tell them to stop. Then, whenever I add anything I need to make sure that it knows not to run if the gamestate says it’s paused. Which is easily forgettable and prone to bugs I guess. Especially if working with a team, as someone could easily overlook it. As others have said, just use unscaled time when dealing with the animations.
You can just turn the whole physics engine off you know. I don't remember the syntax, but it's just one call to some method. And as for time scale, I agree that it should be 0 during the pause.
This tutorial's method is just unnecessarily complicated. The issues he mentioned can easily be solved. You can easily set animations to use unscaled time. As for timers, one can easily increment time.unscaledDeltaTime i.e myTimer += Time.UnscaledDeltaTime; For the paused state, you can just use a bool listener i.e paused = Time.timeScale == 0; Nice video anyway.
@@BaremetalBaron man every game I made was dead simple programmed: a Main game manager with sub managers controlling each part of the game. I dont even use events (my games are tightly coupled) but I never had an issue maintaining the code. Then again I think I may not have made the "big" games. I am trying to learn these "programming" patterns, unit testing etc but I am so less interested for some reason.
@@HassaanALal A lot of popular "best practices" for programming are actually useless nonsense. Or at least overused in places they aren't necessary. As Mike Acton (a former lead engine developer at Insomniac, now works at Unity) put it: trying to solve problems you probably don't have creates a whole bunch of new problems you definitely do.
Thank you! This tutorial really helped me, and I appreciated how quick you went through with this one. I really didn't want to use Timescale as it felt like I wouldn't have any control.
While I agree that time scale does break things with timers and animations this can be easily solved by using unscaled time for said animators and timers however I do agree that it gives more control which is why I implement a similar system which uses timescale in addition to events. I'm curious as to what your approach would be if you wanted to freeze things during your pause like your character animators so as not to transition to the next frame or to freeze random physics objects in game. Would you be creating additional scripts for each object to handle these things?
"While I agree that time scale does break things with timers and animations this can be easily solved by using unscaled time for said animators and timers" no, it doesn't. that's the intended behavior, which is why there's unscaled time for when you don't want it. behaving according to the intended behavior, however much it might not suit your specific case, is not "breaking things".
The problem with this is that A LOT of stuff will not pause in this method. Animations, Particle System, Rigidbody physics, shader effects that use time, VFX Graph prolly. All this does is stop some monobehaviour scripts. It would be simpler to have your own monobehaviour child that handles a lot these functions. But even then. Not to mention you have unscaled animations for animations, and unscaled time for co-routines. And event calls still work. You can have a full game even when timescale is set to 0.
While I admire the Redux-style organization of events, this level of complexity is going to cause problems with physics as frames get lower on older machines. When FPS drops below 60, I've noticed that physics updates start to happen almost on another thread, and physics objects will iterate when your Update() code is in mid-execution. Simply changing timescale is one operation, and the physics objects will immediately get the memo in time. Yes, you can subscribe physics objects to this system, but the pause effect will not propagate immediately, and this could create noticeable desync on slower machines, even as low as 50 FPS. For anything that needs running timers, they can use unscaled time easily enough. For anything else that needs a boolean pause state, you can make a get property that translates timescale being zero or not. I feel like the organization and control of this system is elegant, but it adds a lot of complexity really fast, and having a lot of physics objects in a game is going to cause issues, especially during a lag spike or laggy session. I do recognize the problems you're trying to solve with this implementation, but we have unscaled time for a reason, and physics-heavy games might not be able to use this. If you're using timescale zeroing, your method in the video would still be really good for coordinating control input from the player, and propagate it correctly based on pause state, though. I had to use this for switching between game controls and menu controls a few times before, and it saved my project lol.
Wait, am I missing something? Where in the other objects like the player cube object did you actually check whether the gamestate is paused or not and alter their behaviour accordingly? Or did you just skip over that part? Just setting a variable in a singleton doesn't do anything unless all other objects are told how to behave according to how it changes. And I guess that's the reason why people use the timescale, because they notice at some point that they want to pause and timescale allows to do it without adding a parent state to all other gameobjects.
While I think this is a great method to gain more control over your scripts, I'd like to point out that this method doesn't work very well pausing rigidbodies. Yes, you could theoretically just mark them as kinematic on command, but you'd have to do it for every rigidbody you want to pause, and I think they would lose their velocities. Nevertheless, it's always great to have options, and I loved how quick and precise were your explanations, great video.
i don't get it... what am i missing here? setting timescale to 0 is what pauses the game, however, what specific function is exactly pausing the game here? are we manually disabling running elements when paused is invoked?
He is setting the game object's enabled state to whether or not the game state is Gameplay. If not, then enabled property would be false, pausing that one specific game object. You would have to put this conditional in every game object you want to pause.
Well this is interesting, let me give some useful tipp: in order to have a structured code use empty GameObjects as sort of reference , then you can attach scripts and can establish a architecture . Depending on the scale of the game , you can save those gameobject to file system and load them as per need mode, this would allow to increase performance. Really important question: How many GameObjects should have script as component, well i always try to minimize that and attach scripts to GameObject, only if absolutely necessary, otherwise i dont attach scripts as components. Why? Well then i can easy unit test the scripts ;)
This is not a "much better way" this is a different way. And how much better it is dependent on what you are making. It is rather the correct way to get more control over what pauses. Really good video, and just needs a bit more info imo. I get that's it's hard to make a video, short and have all the info ;)
Okay, I actually wound up copying this because I wound up having a gameplay element where I needed to pause only certain characters, and this served as a useful starting point. I still use the classic "timescale to zero" method for the normal pause because it will cover everything without having to think about it, but this is useful for selectively pausing objects.
This implementation is nice. You still can use timeScale, but with that implementation you can handle another things that can be paused and songs, animations and physics
It's not. It's worse in almost every conceivable way. More brittle, more likely to break, harder to maintain, harder to understand, it's just bad. Just set timescale to 0 for the main pause logic, and then have those few elements that need to continue animating use unscaled time.
I can see how this would be a good way to handle where in code to set timescale to 0, but I really don't understand how it could replace timescale. How would this work with dozens / hundreds of different physics objects across a game? Would they all require individual code to be told to pause? What about just simple 2d rigidbody objects with gravity - would we have to turn off gravity for each one individually?
I'm curious whether this is just something you learned/came up with and are sharing theoretical benefits, or if this is actually something that you have experience with in a larger project and found these benefits to be worth it.
I am not sure if this solution is good enough. Should I subscribe to the event in every script to pause it. For example if I have enemies, moving platforms and many other objects with their own scripts, should I go to every script and write OnGamePaused or something like that and disable the script?
does this require a subjective pause for each class to listen to pause state or am I missing sth? what happens when state change flag is raised? this looks like complicating things through observer pattern with no actual pause method.
The animation not working if there is math in them is very true! And I'm one of them who use time scale, i created.. was it if statement to check if the time scale is above 0 then the math is done and if less it will stop calculating so the animations wont brake. definitely i crate a small test to see this out !
Works the same for Godot. It has an option to set the time scale, but this also interferes with things you don't want paused. This is a good way to control it imho.
Instead of handling pausing per-object manually every time, create an abstract class that inherits from MonoBehaviour called PausableBehaviour. Give it 2 virtual, empty functions called UpdateUnpaused and UpdatePaused. Then, override the Update function (and make it final) to check for a local boolean isPaused, which is set to true/false based on the pause and unpause events. If isPaused is set, make Update call UpdatePaused, else call UpdateUnpaused. Then, make your game objects inherit off PausableBahviour rather than MonoBehaviour, and you will automatically have access to override the PausedUpdate and UnpausedUpdate functions for different functionality without rewriting anything. Or, even better, don't use this terrible tutorial and make a better pause method in the first place.
Yea, i had a hard time to pause game without breaking the UI Animation... BUT I NEED YOU TO TEACH ME HOW TO REALLY USE DELEGATES, CONSTRUCTORS, STATIC REFERENCE, AND ALL OF THOSE THING...
Oh God, this dude used to create a pause enum, a constructor and a get/set and a few scripts ... It's strange why he did not create a library with inheritance of different classes for this. He could have come up with a separate programming language for this.
this is insane lol....I mean this might work for some tiny games, but now you have issues where you're going to have to pause/unpause animations manually, you'll have to freeze/unfreeze physics...it's just an insane amount of work. I'll just tolerate animations resetting themselves
What you *actually* want to do is promote the static Time class to an object. Then you can have multiple TimeProvider objects for each component of your game and control them individually. Usage example: gist.github.com/h-sigma/2e238000c6fb7c16494a4100ac8aa536
This maybe worst pause implementation. There's much more gameplay objects to pause than ui objects to animated. Just need to pause manually on changes tate: animations audio coroutines animators fixed updates and so more. I would think in very opposite direction. On TIMESCALE == 0 YOU CAN STILL USE ANIMATIONS , AUDIO AND COROUTINES. In one manager you can imitate coroutine to update routine and register all monobehqviours that still need to be updated with update method iusing unscaledtim3delta
this videos implies that using timescale to pause the game is wrong which is not true, besides, everything you mention at the end as a benefit from using this implementation can also be used using a simpler timescale implementation, i can see this getting messier and messier once you need to define a paused behaviour for a lot of different classes
What about particle systems and moving physics? IMO you just need some IsPaused bool across the game for your scripts to reference it, but also use timeScale = 0 to easily pause Unity stuff.
Many people seems angry about this, but i have an opinion that this could be useful, yes many people hate the Singleton but you could replace it, and if you ever played the game called "Sniper elite" You know that there is a lot of camera cinematic shot and slow motion, you could take advantage of disabling player control while manipulating timescale to create slow motion effect
"find a script that will be affected by pausing" - like almost all of them? Do I need to put all this amount of code in every script that is affected by pause?
Look, I get most of the things in here and how they work. Not to privy to the whole invoke/listener thing yet. But I don't understand, how does this pause the game? Do you have to program in the pause? Like tell everything to stop manually?
The subscriber handles the pause logic based on what the subscriber does, for example, pausing an audio source. I’ve included some examples of how you can pause certain scripts in the description of the video.
Just a quick question, If you have an object with velocity variables, then you pause the game, do the variables changed to 0, then revert back to what they previously were. Or do the variables stay the same and movement does just not take place?
The best of part of this approach is that you can decide on how to handle that scenario, you don’t have to work around the Unity timescale. Since this approach doesn’t change timescale, the velocity will not be automatically set to 0, so it’s up to your implementation on how you stop an object from moving. One way you could try could be to set the velocity to zero and save the current value on pause and then reset the velocity to the saved value on resume. Don’t be afraid to explore more options!
@@JamesMakesGamesYT But isn't that laborious to go over all moving objects and set their velocities one by one? Do you also use a script called RigidBodyManager or something like that to manage all physics-related objects?
@Alex Fu You're right, it can be a bit laborious. The main benefit of the approach in this video is it gives you more control across multiple game states. The downside is you have to write more code to handle this behaviour. One way around this is to try to re-use common code throughout your scripts, through creating helper methods or through using base classes. Hope this helped
The enabled variable comes from the base MonoBehavior class. When we set enabled to false, it will stop any updates on the component until enabled is set back to true. Hope this helps!
Your code doesn't work, triple checked everything, escape key does nothing with the correct pause controller script attached to the gamemanager object in the scene. Unfortunately, time was wasted.
Might be worth double checking your project is using the old Unity Input method rather than the new InputSystem. I wrote this code to work with the old approach.
I thought the way to avoid Animator issues was to just set those to unscaled time in the Animator. I mean this also can crop up other issues. I mean this is elegant but I can see some issues trying to apply it to the system I have. For example in my case I have a weapon controller that likes to know who owns the controller, it can get this one of two ways, 1 from the player or 2 from the weapon it is controlling. If there is no player it will look for a weapon(disabled via this method), but if there is no weapon or player we have an issue. So there are a ton of ways to work around this for example making the weapon controller look for the asset similar to the weapon it cared about but it just seems like a lot when the alternative is a check box in the animator. Anyway nice video.
Hey, I really like your tutorial, and it's very good, but I found out that if your pause menu changes the game time to 0 you can just put anything that you want to be paused inside an if statement like this: if (Time.timeScale == 1) Everything gets done faster and simpler. This is just to help out anyone who didn't quit understand this video. Anyway keep up the great work
Hey, thanks for the comment, glad you liked the tutorial. That's right, you can set the timeScale to 0 and that will pause the game. This works really well for small projects. However, as your game gets bigger you might want to include things that depend on game time, such as animations or timers. With the approach in the tutorial, you can expand it to handle other game states by adding new values to the enum, such as CutscenePlaying or LevelLoading. This will allow you to handle pausing all enemies while the level is loading or stopping the player from moving and shooting in a cutscene Hope this helped!
@@JamesMakesGamesYT This was just what I was looking for. I wanted to play a Game Over Animation, but the Animation ignores the Time Scale set to 0. You are the only one explaing this so good. I was hopeless. How did you achieve that solution?
@Axy I'm glad this helped you solve your problem! As to how I came up with this solution, I work as a software developer and I've used event systems like this to handle changes that affect the whole system. I intend to share some more experiences of my software developer job and how it can help with game development and personal projects, if that interests you
@@JamesMakesGamesYT I really think you should be glad anyways because this solution works just fine anyway, it's hard to find a bug that this tutorial cannot solve. Grats! P. S. This solution is very concise.
To the nay sayers in comments, this is how you are supposed to pause. Dont be lazy and sloppy take your time to make your game right. Events are efficient and performant and this removes any bugs with pausing from the various other lazy methods.
this really sounds complicated since this is my first video i watched on unity while also not even asking for it, but i enjoyed this anyways since learning about code is interesting to me just enough that it keeps me thinking, i immediately thought that timescale would be wrong thinking about how timers are dumb and easily broken, like a timer on jumps in most games when using timescale allows players to jump in the air via pausing and waiting a bit to then jump before landing and then repeating in order to break the game, while i've no clue if i want to get into unity or any coding for that matter, this seems really cool and interesting, i enjoyed this : )
Hi Chris, once you've imported the Unity Input System into your project and created a new input actions asset, you can select your input action asset and in the inspector check the "Generate C# class" checkbox. You can change the file path of the C# class from the inspector too. Hope this helps!
@@JamesMakesGamesYT thanks mate I actually figured that out shortly after commenting. Do I have to manually set all the inputs again through the new manager or could I just click the generate option and still have use of my inputs ?
Keep up making videos! I see this channel has a ring attached to it and you will become popular just like Brackeys or others. By the way, nice editing.
I don't see how this pauses the CharacterController. I just see you subscribe/unsubscribe to the event but you don't show what you do when the event happens. Also in the Update you are still updating by Time.deltaTime, so Time scale is still going to be a factor. Edit: Nevermind, I see now at 1min in that you are enabling/disabling the object on Pause. It went by soo quick and I couldn't find it when scrubbing the vid timeline.
Great question! For this implementation, I went with the switch because the logic for what to do when the state changes is determined by the subscribers. If you went for an approach where there was a global game state handler, then it might make sense to create classes based off a GameState interface. You could also use the interface approach within one of your subscribers too, if needed
Sorry maybe I missed something but when in this tutorial are you actually pausing the game? Sure you're using events for sending state messages but I have not seen any of them affecting the player.
I was wondering the same thing but I found on the PlayerController script within the OnGameStateChanged(GameState newGameState) method, you'll see "enabled = newGameState == GameState.Gameplay)" - That will enable/disable the component when the event is invoked. (this is shown about the 1:00 mark)
Thanks for answering! But again in this instance is he suggesting that we enable/disable a component to stop the game? That won't stop the player if for example you're using a rigid body. The player would still move if you disabled the player movement component. Also how do you stop for example a particle simulation? If I disable the particle component that just makes it disappear and inactive it doesn't pause the particle effect. This video is nice in teaching how to use events and a good foundation for the Observer pattern but I'm not convinced that it is a good way to actually pause the game... At least until he can demonstrate how to pause other aspects of the game
I don't think using Animators for UI is a good idea for most use cases anyway. Tweening is way more efficient. And it doesn't need an extra Tweening solutions as most people would think, as you can actually use animation curves from code.
@@L0upyb0y Animations give more control over UI. With tweening it gets way too complicated to animate multiple properties and elements at once. As for efficiency they both force the canvas to recalculate so there is no real difference. The best optimization here is to use nested canvases.
this pause system you mention in the video Sounds completed and I don't think it's the best paused system for my game 1. in my I have a lot of different codes I have physics audio animation ECT and i personally don't want to create specific event for each off my code or section my game have this sounds like nightmare to create 2. with using time scale the handle all those stuff and I only have to create pause acception spefic cases like for example let's say that I have button that appears and disappear a object the time scale don't change that however it's very easy to use time scale and just create acception in specific Case
How do you normally pause your game in Unity? Will you try using events in the future?
What if you use Unity Phisics + have some TweenAnimations in Game
And when your game pause you need to Stop Update it???
State machine doesn't work here
So I think the video is misleading.
nuh, my whole game procedurally generated and has a lot of ai handling by coroutines, so setting Timescale to zero is the better way
Timescale is easier because there is less to learn and less to type. But it's also the lazy way to do it. I have often had trouble with Timescale messing with my animations or my UI, so this might be better in those cases. Nice to know there is another option. But of course Unity and C# always have multiple ways of doing things, so it entirely depends on your current code and how your project is put together.
while (true){}, game doesnt run anymore count toward pause right?
@@khiemgom 🤣
I guess it depends what you consider as pause, for example I want to "freeze" the whole world, so animations, physics etc should stop while in pause, so setting TimeScale to 0 makes more sense in that case, otherwise I would have to manually pause all animators etc. For the few animations that should still play (for example pause menu) I can just change the animator to unscaled time so they will still work just like before.
Yeah, I get the idea of this video, but to hook up everything in your code base to this event to respond properly to a pause sounds like a nightmare. For the few things I want to not be completely paused or have some special pause behavior I'll handle those exceptions accordingly. Also, not that you have to our should listen to Unity, but they recommend pausing with time scale.
@@Feral_Pug_Codes Just use Godot. That engine actually has a pause function.
@@poseeley yeah when i have some free time I definitely plan to check out Gadot. I really like what I'm seeing over there, and not do much with Unity
@@Feral_Pug_Codes I was being a little facetious. I can't believe that this function isn't in Unity by default. Similar story with timers. I used to think Unity was the best. >.>
@@poseeley It just depends on what TYPE of "pause" you want. Godot has a built in "pause" function where you can pause the whole thing, or leave things active.
Unity has the same thing....which is Timescale.
Some devs want the day and night, NPCs to pause, but crafting stations to continue.
Some want only player to pause.
Various other combos.
Thats what Timescales can control. Plus you can have an interface that will allow to speed up or slow down time AND pause.
Can do the same in Godot, but some scenarios can take alot more code and workarounds.
Unreal gives a ton of control too.
>Artificially sped up audio to sound like you have confidence
>Engine has built-in ways to arbitrarily speed up/slow down the game including full stop
>It also has built-in solution for the exact same problem shown in the video by just using unscaled time
>You can still make pause event that some script can subscribe(like audio sources that don't automatically "pause" from timescale) that can have special logic on pause
>Have a public get private set property AND have a set method
>Every single script that should pause is the exception and not the other way around which makes the entire codebase very bloated
Yeah, no. I agree that just simply setting timescale to 0 is not enough, this is just overcomplicating things. Novice developers are gonna watch this and make their game too complicated that they can't work on it anymore. Don't reinvent the wheels. Make them better.
EDIT : also, "GameState" enum is not needed unless you are planning to add multiple pause state which is pretty rare. A simple bool would be more than enough. GameStateChangeHandler delegate is not needed and you can just use Action to make your life a lot easier. Singletons that instances itself can generally be replaced with static classes that do much of the same thing. It's easier to write GameStateManager.Pause() than GameStateManager.Instance.SetState(GameState.Paused) which is a lot longer with not much more context.
Yep as per usual this dude learned this last week and is posting it in a short format that's taking off because of Tarodev and others. This tutorial overcomplicates simple pausing by like 4 completely unnecesary states. Pausing one way or the other is NOT wrong. There are situations for everything.
i personally dont like having singletons and god class, I wonder where did those conventions come from?
I thought this looked way too complicated 😅 nice to see someone answer this!
But it begins to push game developers pass the basic. What he's teaching isn't wrong, just another method to do the same thing, except his allows for more granular control.
This is a super naive solution. ^^
Okay, but this requires you to add this to every single object that could be effected by a pause, and if you miss anything it would put holes int he game that could seriously break things.
Alternatively you could just use unscaled time to animate your UI.
@@mikkelens It sounds fun to add this into everything... You can use it if you want, but it's just sounds like multiple hours of extra work for the same effect which you can get via 2 lines of code...
@@mikkelens Quite frankly, no, I wouldn't rather have that. Especially as my game scales more and more and grows bigger. Every new element I introduce into my game is another thing that potentially could screw up when I try to pause. But with adjusting the time scale, literally the only thing I have to fix is the pause menu itself. No matter how much bigger my game grows, I will never need anything more to be active when the game is paused.
This is actually how it should be done in game framework, everywhere. Which means all your framework objects should subscribe to game events throughout inheritance (automatically). Otherwise you will end up with many objects cheking for game states or worse, trying to setup timescale at the same time. Unity encourage very bad coding practices.
@@tatoforever Honestly, that really comes down to the structure you need for your project. I certainly respect the idea of setting up pause actions through inheritance, and that would be very easy to do in Unreal where you have access to these base classes. But with Unity's structure you can't apply that code to the base monobehavior, so you have to ask: Am I more likely to create a script and forget to have it inherit from a pausable class, or am I more likely to have some other random script adjust the time scale.
I'm sure if I was doing a lot of ramping effects in my game it may be more reasonable to incorporate a pause function into some base classes. But if that's not a thing, then relying on time scale to control pausing is safer.
just put it all in a base class, no repetition necessary
As for me, much easier and readable to use timescale and unscale properties where you need, rather make every single timer and movement script depends on pause flag. There is not so many situations, where you really need to overcomplicate pause in this way
yep same
Yep, this video gave me flashbacks to implementing pause in engines which don’t support it, like Fusion. Screw that.
I would still recommend doing the actual pausing/unpausing itself in your game manager rather than setting timescale manually in your scripts, because that way you can centrally manage it. This way, if you ever need to change the timescale for some other reason, such as bullet time, you can pause/unpause the game while maintaining the correct timescale (unpausing back to bullet time), as well as managing timescale in other ways.
@@pt8306 imho, it's still sound like very situational thing
Totally agree.
Hm, would make far more sense to pack all of this into a GameStateBehaviour script, and just inherit from that on any classes that need to be paused - otherwise you're bloating your code by adding nearly identical boiler-plate pausing code to tons of different scripts.
Also, if all pause-able classes inherit from the same base, the reused code only needs to be changed in one place, for any unforeseen future updates farther down the line.
I would make the private methods OnGameStateChange(), Awake(), and OnDestroy() into protected virtual methods: they can now be easily overridden if the code needs to execute differently on one script, while all still using the SAME pipeline for pausing and resuming.
the only code you're adding is the event subscription. any other code that you would have is pause behaviour u would have had anyways.
RUclips: recommends Unity video
Me, who doesn't even know unity: Hmm, interesting 🤔
What he’s essentially using is called “the observer pattern”.
But this does complicate things somewhat. Like for myself, I’m making a 3D platformer. If my character jumps and I want to pause using this method, I then need to make sure everything in its script is canceled, especially making sure that gravity is not longer applied or the character will still fall. His animations will also still play unless I tell them to stop.
Then, whenever I add anything I need to make sure that it knows not to run if the gamestate says it’s paused. Which is easily forgettable and prone to bugs I guess. Especially if working with a team, as someone could easily overlook it.
As others have said, just use unscaled time when dealing with the animations.
You can just turn the whole physics engine off you know. I don't remember the syntax, but it's just one call to some method.
And as for time scale, I agree that it should be 0 during the pause.
This tutorial's method is just unnecessarily complicated. The issues he mentioned can easily be solved.
You can easily set animations to use unscaled time.
As for timers, one can easily increment time.unscaledDeltaTime i.e
myTimer += Time.UnscaledDeltaTime;
For the paused state, you can just use a bool listener i.e
paused = Time.timeScale == 0;
Nice video anyway.
this is how I usually work, but i feel i might be wrong and need to follow the standards like in these videos..
@@HassaanALal No, what you're doing is fine. What this video is doing is just hilariously over-engineered for very little benefit.
@@BaremetalBaron man every game I made was dead simple programmed: a Main game manager with sub managers controlling each part of the game.
I dont even use events (my games are tightly coupled) but I never had an issue maintaining the code. Then again I think I may not have made the "big" games. I am trying to learn these "programming" patterns, unit testing etc but I am so less interested for some reason.
@@HassaanALal A lot of popular "best practices" for programming are actually useless nonsense. Or at least overused in places they aren't necessary.
As Mike Acton (a former lead engine developer at Insomniac, now works at Unity) put it: trying to solve problems you probably don't have creates a whole bunch of new problems you definitely do.
Thank you! This tutorial really helped me, and I appreciated how quick you went through with this one. I really didn't want to use Timescale as it felt like I wouldn't have any control.
While I agree that time scale does break things with timers and animations this can be easily solved by using unscaled time for said animators and timers however I do agree that it gives more control which is why I implement a similar system which uses timescale in addition to events.
I'm curious as to what your approach would be if you wanted to freeze things during your pause like your character animators so as not to transition to the next frame or to freeze random physics objects in game. Would you be creating additional scripts for each object to handle these things?
"While I agree that time scale does break things with timers and animations this can be easily solved by using unscaled time for said animators and timers"
no, it doesn't. that's the intended behavior, which is why there's unscaled time for when you don't want it.
behaving according to the intended behavior, however much it might not suit your specific case, is not "breaking things".
I’ll remember I knew you before you had 1,000 subs! Good video.
I was looking for a way to create an 'active pause' in Unity and stumbled upon your video. Thank you for getting straight to the point
Glad the video helped!
The problem with this is that A LOT of stuff will not pause in this method.
Animations, Particle System, Rigidbody physics, shader effects that use time, VFX Graph prolly.
All this does is stop some monobehaviour scripts. It would be simpler to have your own monobehaviour child that handles a lot these functions. But even then.
Not to mention you have unscaled animations for animations, and unscaled time for co-routines. And event calls still work. You can have a full game even when timescale is set to 0.
this was not pausing the game, u just stopped doing what u doing in update, could use a bool as well instead of events to demo this :D
While I admire the Redux-style organization of events, this level of complexity is going to cause problems with physics as frames get lower on older machines.
When FPS drops below 60, I've noticed that physics updates start to happen almost on another thread, and physics objects will iterate when your Update() code is in mid-execution.
Simply changing timescale is one operation, and the physics objects will immediately get the memo in time. Yes, you can subscribe physics objects to this system, but the pause effect will not propagate immediately, and this could create noticeable desync on slower machines, even as low as 50 FPS.
For anything that needs running timers, they can use unscaled time easily enough. For anything else that needs a boolean pause state, you can make a get property that translates timescale being zero or not.
I feel like the organization and control of this system is elegant, but it adds a lot of complexity really fast, and having a lot of physics objects in a game is going to cause issues, especially during a lag spike or laggy session.
I do recognize the problems you're trying to solve with this implementation, but we have unscaled time for a reason, and physics-heavy games might not be able to use this.
If you're using timescale zeroing, your method in the video would still be really good for coordinating control input from the player, and propagate it correctly based on pause state, though. I had to use this for switching between game controls and menu controls a few times before, and it saved my project lol.
Wait, am I missing something? Where in the other objects like the player cube object did you actually check whether the gamestate is paused or not and alter their behaviour accordingly? Or did you just skip over that part? Just setting a variable in a singleton doesn't do anything unless all other objects are told how to behave according to how it changes. And I guess that's the reason why people use the timescale, because they notice at some point that they want to pause and timescale allows to do it without adding a parent state to all other gameobjects.
While I think this is a great method to gain more control over your scripts, I'd like to point out that this method doesn't work very well pausing rigidbodies. Yes, you could theoretically just mark them as kinematic on command, but you'd have to do it for every rigidbody you want to pause, and I think they would lose their velocities. Nevertheless, it's always great to have options, and I loved how quick and precise were your explanations, great video.
I have found that making an object kinematic while inside a trigger invokes OnTriggerExit for that object so its a bit dangerous
It is worth remembering that each += is the creation of a new object and each Invoke() is a call to a virtual method.
i don't get it... what am i missing here? setting timescale to 0 is what pauses the game, however, what specific function is exactly pausing the game here? are we manually disabling running elements when paused is invoked?
He is setting the game object's enabled state to whether or not the game state is Gameplay. If not, then enabled property would be false, pausing that one specific game object. You would have to put this conditional in every game object you want to pause.
Thanks for making this video, really needed
Well this is interesting, let me give some useful tipp: in order to have a structured code use empty GameObjects as sort of reference , then you can attach scripts and can establish a architecture . Depending on the scale of the game , you can save those gameobject to file system and load them as per need mode, this would allow to increase performance. Really important question: How many GameObjects should have script as component, well i always try to minimize that and attach scripts to GameObject, only if absolutely necessary, otherwise i dont attach scripts as components. Why? Well then i can easy unit test the scripts ;)
What is the function of GameStateActiveController Sritpt on the Pause Screen? The code wasnt displayed on the video
I've linked all the code in the description to help you out!
This is not a "much better way" this is a different way. And how much better it is dependent on what you are making.
It is rather the correct way to get more control over what pauses. Really good video, and just needs a bit more info imo. I get that's it's hard to make a video, short and have all the info ;)
Really appreciate these short very educational videos.
So complex in just 2 minutes, and it feels sooo clean, amazing work
Okay, I actually wound up copying this because I wound up having a gameplay element where I needed to pause only certain characters, and this served as a useful starting point.
I still use the classic "timescale to zero" method for the normal pause because it will cover everything without having to think about it, but this is useful for selectively pausing objects.
Why this video hasnt get to 100,000 views? This is really helpful
Thanks Alejandro! Glad you found the video helpful!
This method is too complicated but thanks for sharing
No worries, I appreciate the feedback!
This implementation is nice. You still can use timeScale, but with that implementation you can handle another things that can be paused and songs, animations and physics
I have no doubt this is better but I don't understand any of this yet. Good video though, since now I know there are better ways of doing this.
It's not. It's worse in almost every conceivable way. More brittle, more likely to break, harder to maintain, harder to understand, it's just bad.
Just set timescale to 0 for the main pause logic, and then have those few elements that need to continue animating use unscaled time.
Well honestly if you don't understand it you can't guarantee it's better or not.
I can see how this would be a good way to handle where in code to set timescale to 0, but I really don't understand how it could replace timescale. How would this work with dozens / hundreds of different physics objects across a game? Would they all require individual code to be told to pause? What about just simple 2d rigidbody objects with gravity - would we have to turn off gravity for each one individually?
Man, u've create nice content, sad to see that channel is abandoned :(
Not abandoned, just on hiatus!
But this only pause the controls, no? Unless you add each classes in each objects that are affected by pause
I'm curious whether this is just something you learned/came up with and are sharing theoretical benefits, or if this is actually something that you have experience with in a larger project and found these benefits to be worth it.
The best way to pause unity game is to click the pause button next to the play button in unity
Harvard wants to know your location
I am not sure if this solution is good enough. Should I subscribe to the event in every script to pause it. For example if I have enemies, moving platforms and many other objects with their own scripts, should I go to every script and write OnGamePaused or something like that and disable the script?
Nice info, thanks.
what about things that can't be controlled this way, such as physics?
does this require a subjective pause for each class to listen to pause state or am I missing sth? what happens when state change flag is raised? this looks like complicating things through observer pattern with no actual pause method.
The animation not working if there is math in them is very true!
And I'm one of them who use time scale, i created.. was it if statement to check if the time scale is above 0 then the math is done and if less it will stop calculating so the animations wont brake.
definitely i crate a small test to see this out !
how can i do this except animating a camera and let a character do a special move while everithing else is freeze?
Missing "GameStateActiveController" script explanation and code example....
Works the same for Godot. It has an option to set the time scale, but this also interferes with things you don't want paused. This is a good way to control it imho.
Instead of handling pausing per-object manually every time, create an abstract class that inherits from MonoBehaviour called PausableBehaviour. Give it 2 virtual, empty functions called UpdateUnpaused and UpdatePaused. Then, override the Update function (and make it final) to check for a local boolean isPaused, which is set to true/false based on the pause and unpause events. If isPaused is set, make Update call UpdatePaused, else call UpdateUnpaused. Then, make your game objects inherit off PausableBahviour rather than MonoBehaviour, and you will automatically have access to override the PausedUpdate and UnpausedUpdate functions for different functionality without rewriting anything. Or, even better, don't use this terrible tutorial and make a better pause method in the first place.
This is pretty clever. Thank you for an actual answer.
timescale has more advantages, you can keep animations working, and you can make the timescale interpolate.
Yea, i had a hard time to pause game without breaking the UI Animation...
BUT I NEED YOU TO TEACH ME HOW TO REALLY USE DELEGATES, CONSTRUCTORS, STATIC REFERENCE, AND ALL OF THOSE THING...
can it be used to slow down specific gameobjects?
How can you turn off the physics engine?
Oh God, this dude used to create a pause enum, a constructor and a get/set and a few scripts ... It's strange why he did not create a library with inheritance of different classes for this. He could have come up with a separate programming language for this.
this is insane lol....I mean this might work for some tiny games, but now you have issues where you're going to have to pause/unpause animations manually, you'll have to freeze/unfreeze physics...it's just an insane amount of work. I'll just tolerate animations resetting themselves
What you *actually* want to do is promote the static Time class to an object. Then you can have multiple TimeProvider objects for each component of your game and control them individually.
Usage example:
gist.github.com/h-sigma/2e238000c6fb7c16494a4100ac8aa536
I was just thinking of a concept like this, although I'm not sure how easy or useful is to implement on Unity
This maybe worst pause implementation. There's much more gameplay objects to pause than ui objects to animated. Just need to pause manually on changes tate: animations audio coroutines animators fixed updates and so more. I would think in very opposite direction. On TIMESCALE == 0 YOU CAN STILL USE ANIMATIONS , AUDIO AND COROUTINES. In one manager you can imitate coroutine to update routine and register all monobehqviours that still need to be updated with update method iusing unscaledtim3delta
this videos implies that using timescale to pause the game is wrong which is not true, besides, everything you mention at the end as a benefit from using this implementation can also be used using a simpler timescale implementation, i can see this getting messier and messier once you need to define a paused behaviour for a lot of different classes
What about particle systems and moving physics? IMO you just need some IsPaused bool across the game for your scripts to reference it, but also use timeScale = 0 to easily pause Unity stuff.
Many people seems angry about this, but i have an opinion that this could be useful, yes many people hate the Singleton but you could replace it, and if you ever played the game called "Sniper elite" You know that there is a lot of camera cinematic shot and slow motion, you could take advantage of disabling player control while manipulating timescale to create slow motion effect
"find a script that will be affected by pausing" - like almost all of them?
Do I need to put all this amount of code in every script that is affected by pause?
What about physics in this method? I dont think its easy to pause all Physics simulations in this method
Wow that very cool! But i'm afraid of singletons, is there a way to make it without singleton?
"the RIGHT Way" and proceeds to implement a singleton.
Look, I get most of the things in here and how they work. Not to privy to the whole invoke/listener thing yet. But I don't understand, how does this pause the game? Do you have to program in the pause? Like tell everything to stop manually?
The subscriber handles the pause logic based on what the subscriber does, for example, pausing an audio source. I’ve included some examples of how you can pause certain scripts in the description of the video.
Just a quick question, If you have an object with velocity variables, then you pause the game, do the variables changed to 0, then revert back to what they previously were. Or do the variables stay the same and movement does just not take place?
The best of part of this approach is that you can decide on how to handle that scenario, you don’t have to work around the Unity timescale.
Since this approach doesn’t change timescale, the velocity will not be automatically set to 0, so it’s up to your implementation on how you stop an object from moving. One way you could try could be to set the velocity to zero and save the current value on pause and then reset the velocity to the saved value on resume.
Don’t be afraid to explore more options!
@@JamesMakesGamesYT But isn't that laborious to go over all moving objects and set their velocities one by one? Do you also use a script called RigidBodyManager or something like that to manage all physics-related objects?
@Alex Fu You're right, it can be a bit laborious.
The main benefit of the approach in this video is it gives you more control across multiple game states. The downside is you have to write more code to handle this behaviour. One way around this is to try to re-use common code throughout your scripts, through creating helper methods or through using base classes.
Hope this helped
i like this idea. but i think i'll stick to timescale to 0 so i can manually animate specific things like the pause menu to an unscaled time.
A public State property with a private setter AND a Java style SetState() method? Why the confusing mixing? Why not just use one or the other.
Another negative from timescale to 0, the UI clicking behavior gets glitchy
Why is there that enable variable on player script?
The enabled variable comes from the base MonoBehavior class. When we set enabled to false, it will stop any updates on the component until enabled is set back to true. Hope this helps!
Your code doesn't work, triple checked everything, escape key does nothing with the correct pause controller script attached to the gamemanager object in the scene. Unfortunately, time was wasted.
Might be worth double checking your project is using the old Unity Input method rather than the new InputSystem. I wrote this code to work with the old approach.
I thought the way to avoid Animator issues was to just set those to unscaled time in the Animator. I mean this also can crop up other issues. I mean this is elegant but I can see some issues trying to apply it to the system I have.
For example in my case I have a weapon controller that likes to know who owns the controller, it can get this one of two ways, 1 from the player or 2 from the weapon it is controlling. If there is no player it will look for a weapon(disabled via this method), but if there is no weapon or player we have an issue. So there are a ton of ways to work around this for example making the weapon controller look for the asset similar to the weapon it cared about but it just seems like a lot when the alternative is a check box in the animator.
Anyway nice video.
Hey, I really like your tutorial, and it's very good, but I found out that if your pause menu changes the game time to 0 you can just put anything that you want to be paused inside an if statement like this:
if (Time.timeScale == 1)
Everything gets done faster and simpler.
This is just to help out anyone who didn't quit understand this video.
Anyway keep up the great work
Hey, thanks for the comment, glad you liked the tutorial.
That's right, you can set the timeScale to 0 and that will pause the game. This works really well for small projects.
However, as your game gets bigger you might want to include things that depend on game time, such as animations or timers.
With the approach in the tutorial, you can expand it to handle other game states by adding new values to the enum, such as CutscenePlaying or LevelLoading. This will allow you to handle pausing all enemies while the level is loading or stopping the player from moving and shooting in a cutscene
Hope this helped!
@@JamesMakesGamesYT This was just what I was looking for. I wanted to play a Game Over Animation, but the Animation ignores the Time Scale set to 0.
You are the only one explaing this so good. I was hopeless.
How did you achieve that solution?
@Axy I'm glad this helped you solve your problem!
As to how I came up with this solution, I work as a software developer and I've used event systems like this to handle changes that affect the whole system.
I intend to share some more experiences of my software developer job and how it can help with game development and personal projects, if that interests you
@@JamesMakesGamesYT Thank you for the answer!
@@JamesMakesGamesYT I really think you should be glad anyways because this solution works just fine anyway, it's hard to find a bug that this tutorial cannot solve.
Grats!
P. S. This solution is very concise.
Me who's currently working on a souls like game:
"Pausing the game? We don't do that here."
and this is what happens when someone who doesnt know wtf they are talking about makes a tutorial.
Nice, but using `UnitEvent` or an Action would eliminate the delegate type, and that's not a thread-safe way of initializing a singleton.
To the nay sayers in comments, this is how you are supposed to pause. Dont be lazy and sloppy take your time to make your game right. Events are efficient and performant and this removes any bugs with pausing from the various other lazy methods.
this really sounds complicated since this is my first video i watched on unity while also not even asking for it, but i enjoyed this anyways since learning about code is interesting to me just enough that it keeps me thinking, i immediately thought that timescale would be wrong thinking about how timers are dumb and easily broken, like a timer on jumps in most games when using timescale allows players to jump in the air via pausing and waiting a bit to then jump before landing and then repeating in order to break the game, while i've no clue if i want to get into unity or any coding for that matter, this seems really cool and interesting, i enjoyed this : )
why you need to write all of them when you can just write in 1?
Hi James , how do I generate the controls class ? Tried looking i can’t find a straight answer lol
Hi Chris, once you've imported the Unity Input System into your project and created a new input actions asset, you can select your input action asset and in the inspector check the "Generate C# class" checkbox. You can change the file path of the C# class from the inspector too.
Hope this helps!
@@JamesMakesGamesYT thanks mate I actually figured that out shortly after commenting. Do I have to manually set all the inputs again through the new manager or could I just click the generate option and still have use of my inputs ?
@@chrisdk5665 If you're migrating from Unity's old input, you'll have to manually create your inputs through the new manager
@@JamesMakesGamesYT thanks mate
Keep up making videos! I see this channel has a ring attached to it and you will become popular just like Brackeys or others.
By the way, nice editing.
Thanks Axy! Are there any topics in particular you’d want to see covered on this channel?
I don't see how this pauses the CharacterController. I just see you subscribe/unsubscribe to the event but you don't show what you do when the event happens. Also in the Update you are still updating by Time.deltaTime, so Time scale is still going to be a factor.
Edit: Nevermind, I see now at 1min in that you are enabling/disabling the object on Pause. It went by soo quick and I couldn't find it when scrubbing the vid timeline.
Glad you managed to get it sorted.
I’m working on the improving the pacing of my future videos
code link cant open :(
Doesn't work, tried to make it work with many and many changes but nothing
well that was pretty good
Great video James!
Thanks Dan!
Would this implementation of the statemachine be better with switch or interface logic?
Great question! For this implementation, I went with the switch because the logic for what to do when the state changes is determined by the subscribers. If you went for an approach where there was a global game state handler, then it might make sense to create classes based off a GameState interface. You could also use the interface approach within one of your subscribers too, if needed
@@JamesMakesGamesYT thanks a lot for the answer!
Sorry maybe I missed something but when in this tutorial are you actually pausing the game? Sure you're using events for sending state messages but I have not seen any of them affecting the player.
I was wondering the same thing but I found on the PlayerController script within the OnGameStateChanged(GameState newGameState) method, you'll see "enabled = newGameState == GameState.Gameplay)" - That will enable/disable the component when the event is invoked. (this is shown about the 1:00 mark)
Thanks for answering! But again in this instance is he suggesting that we enable/disable a component to stop the game? That won't stop the player if for example you're using a rigid body. The player would still move if you disabled the player movement component. Also how do you stop for example a particle simulation? If I disable the particle component that just makes it disappear and inactive it doesn't pause the particle effect. This video is nice in teaching how to use events and a good foundation for the Observer pattern but I'm not convinced that it is a good way to actually pause the game... At least until he can demonstrate how to pause other aspects of the game
i cant reach code links
Nice work
Thanks Benjamin!
I thought I was watching a tutorial
Little did I know it was actually a speedrun.
Great tutorial. I love that you get straight to the point with everything! looking forward to more!
Thanks! I plan on making more straight to the point tutorials in the future so keep an eye out for them!
Right, this is so much more simple and less convoluted... why didn't I think of this?
This method of getting the singleton instance is not thread safe. You should assign the property an instance right away.
How to turn 1 line of code to 50
Well, as for the UI animations, you could just set the animator to be unaffected by timescale haha. But the other points are true :)
I don't think using Animators for UI is a good idea for most use cases anyway. Tweening is way more efficient. And it doesn't need an extra Tweening solutions as most people would think, as you can actually use animation curves from code.
@@L0upyb0y What is tweening? haha, I use animations for my UI all the time, so if there's a better option I'd like to update :P
@@L0upyb0y Animations give more control over UI. With tweening it gets way too complicated to animate multiple properties and elements at once. As for efficiency they both force the canvas to recalculate so there is no real difference. The best optimization here is to use nested canvases.
Just use unscaled time for the things you want to keep running. That is way easier and I never had a problem with it.
Why did we write GameState 38 times in 5 scripts wow
Thanks.
I will just use events in tandem with time scale. Even more control and efficiency.
can you link the code?
Sure! I've added links to the code in the description!
this pause system you mention in the video Sounds completed and I don't think it's the best paused system for my game
1. in my I have a lot of different codes I have physics audio animation ECT and i personally don't want to create specific event for each off my code or section my game have this sounds like nightmare to create
2. with using time scale the handle all those stuff and I only have to create pause acception spefic cases
like for example let's say that I have button that appears and disappear a object the time scale don't change that however it's very easy to use time scale and just create acception in specific Case
Reminds me of MonsterLove's StateMachine
mind blowing o.O