How to PAUSE a Game | Unity Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi game developers do not touch the time scale to pause your game it's a nightmare to manage keep it for game gems instead let's make an abstract class that extends mono Behavior every other mono behavior that needs to be paused will extend this class add a field to decide if you want this object to be posible or not here I have a game manager that keeps track of the state of the game it's called a Blackboard because everyone in the game can look at the Blackboard the Blackboard knows when we pause and when we resume like the pause button might just call the blackboard's pause method and that will trigger an event in our abstract class let's register our methods and we will get notified when the game pauses or resumes on this try we clean up the methods I have some guarding conditions specific for my game but maybe you need something different on pause we wait for it disable this mono Behavior not this game object but this mono behavior only whoever implements this class gets disabled on resume we do the opposite what enable does is it stops this mono Behavior to get updates just updates then we also Define some optional methods that can be overwritten in the concrete class if you want post pause post resume will get called at the end of on pause respectively on resume now if I want for example my NPC vehicles to pause I can extend my gameplay mono behavior and in the inspector I can check possible what I have to pay attention to is if my class needs to do something in awake I must call base. awake first to be sure that everything gets correctly initialized can be refractor to some other pattern as well that's it now you might think dude what about Coe routines that's right Coe routines will not get poed that's why we have post Po and post resume core routines are specific to whatever your concrete class does for example in my fuel controller I consume fuel through a core routine so here I can set some Flags to make sure that the coroutine idles most of the time I prefer to make a coroutine idle and wait rather than killing and restarting it and if you feel very fancy you could even Implement a custom yield instruction to handle that state that's it structured and manageable time scale is for slowmo not for pauses don't be silly that's straight to the point thank you very much for watching like And subscribe now go walk on your game I'll see you next time
Info
Channel: This is GameDev
Views: 2,338
Rating: undefined out of 5
Keywords: make my dream game, how to make a game, made with unity, game devlog, gamedev vlog gamedev, indiegamedev, game dev, indie gamedev, indie game, unity 3d, unity3d, game development, make a game, tutorial, guide, game engine, unity hub, blender 2.8, blender 3.0, blender 3, madewithunity, iOS, Android, mobile game, smartphone game brackeys, thomas brush, jason weimann, jonas tyroller, dani, danidev, blackthornprod gamedev, unity, install, how to, install unity
Id: TZgcXLekIm0
Channel Id: undefined
Length: 2min 11sec (131 seconds)
Published: Wed Jan 10 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.