Комментарии:
Very well explained!!
ОтветитьThis video was absolutely brilliant in how succinct and well-explained it was. The channel deserves way more subscribers.
Out of curiosity - which IDE are you using here? I couldn't work it out.
very nice video:)
ОтветитьThank you very much! Great tutorial!
Ответитьthis a great solution to my the problem i have because like you say time scale effects only the time the have a lot off issues like for example wean you make objects with bool and the are set active or the opiset with having a "is pause" bool or something similar you easy able to make the game better
because you able to disable and enable stern factions like game inputs for example and other stuff you don't wond to happen one other good ideas is to find some way to disabled some off thos faction event the game is not pause for example if someone make i multiplayer game for example it's good idea to make thos system to stop event if not on the pase the game
for example if you play a multiplayer you don't wand to puse the game wean you press the menu but you still wand to disable the player input wean you press this button
i stopped game with time.timescale=0; but i cant work this code "Button.interactable=true;" i searched and i probably i need to solve this with time.unscaledTime but how can i do it? help me plz
ОтветитьBeen looking into some threads and videos, none managed to answer my question...
You see, i got 3 methods, PauseMenu, Inventory Menu and GameOverScreen, all of then use the same structure as this:
public void PauseMenu()
{
if(Input.GetButtonDown("Pause") && isMenu == false && isGameOver == false)
{
isPaused = !isPaused;
PauseScreen.SetActive(isPaused);
}
if(isPaused)
{
Time.timeScale = 0f;
Debug.Log(Time.timeScale);
}
else
{
Time.timeScale = 1f;
}
}
The thing is, only the last modified works, they don´t work at the same time. I have seen that´s because since they do the same thing and Update isn´t affected, it just chooses one and ignore the others, is there a way to circle around this?
Easter Egg Enemy: Unscaled Time Lizard, a lizard with skin instead of scales that is unafected by pausing the game and might just walk up to your character and murder it while the game is paused.
Ответитьniceeee! 🖤
ОтветитьOK dude
ОтветитьNeed to pause the game whenever interacting with npc:s to actually be able to use mouse to answer NPC. Helpful tutorial, thank you.
Ответитьthis is quality stuff. dont stop giving us such amazing content.
ОтветитьGood work bro
ОтветитьThis is a good quality video that solved my problem. Great job !
ОтветитьI read your blog about pause a game.Amazing blogpost to answer almost every question.Thank you
ОтветитьI'm using the new Input System which fires an event when P is pressed. This flips a boolean flag property: it's true, run the Pause logic. If its now become false, run the Unpause logic. Note that this is a C# getter/setter property, not just a boolean variable on its own.
The pause logic sets Time.timeScale to 0 which effectively freezes the main game state, but also uses unscaled time to allow certain other things to carry on (e.g. animations on the pause screen itself). It also uses the Input System to disable/enable certain Actions, to in effect "lock out" certain controls while the game is paused, i.e. the gameplay controls are locked out while the Pause and Quit buttons still work. This prevents the game from going utterly haywire once unpaused again.
I'm convinced my method is absolute crap and fully expect to stumble across a much better and cleaner way at some point.
I still have some problems even if I believe this video gave me a lot of useful information.
I use timeScale = 0 to pause my game when my level loads because It's supposed to wait for the 3 seconds countdown to end and then timeScale goes back to 1.
The problem is that my countdown timer is stopped because of the timeScale = 0 xD
I can't figure out how to only make the timer not afected by timeScale =0.
I recently had issues in my game with using TimeScale at 0 to pause, as it can potentially stop other scripts in the game midway through execution.
The way I got around this was to have the pause button set a bool, then run the check to set the Timescale to 0 in LateUpdate() as this is more likely to run once everything else is finished in that frame.
Amazing video, love how you explain everything and show different examples. Now to watch all your other vids.
ОтветитьFirst of all, awesome video, thanks a ton for sharing this!
Personally I don't modify the timescale at all, but rather keep a collection of tracked objects that are subscribed to the pause event which pause/unpause their behavior.
Very helpful! Thanks for the video
ОтветитьNever quit uploading content, your video quality is really a rare gem to find in the Unity tutorial world these days. This video truly felt like being in a university actually learning something. Keep up the great work.
Ответитьfor some reason my fps goes to -2e+09 when the game pauses why is that?
ОтветитьThis was really helpful. I've traditionally just been using a GameState object that sends out a 'GamePaused' event, and having all of the objects that need to respond to that and set their own 'isPaused' state accordingly, but things with Physics of course don't follow that so that's been a challenge. I totally didn't know you could do this, this helps so much, thank you! Love your blog too!
ОтветитьI’m currently working on a Halo VR game and pausing is turning out to be a pain in the arse, this video helped me so much! Cheers man!
ОтветитьIncredible tutorial, completely surpassed my expectations on this one! Thanks a lot for the help
Ответитьway too good ma boy!
ОтветитьExcellent video! I tried using timeScale=0 and it works great in editor, but in a build Windows says the app is unresponsive after being paused for 15-30 seconds, basically crashing the game. I read something about setting it to 0.001f instead, but that didn’t change it. Do you have any idea on where to look for any code that could cause this to happen? Thanks!
ОтветитьThank you for much. It's really very useful information
ОтветитьThanks for the tutorial.
I've been having a problem with the pause function in my game: i am doing a game about protecting a cell in the middle of the screen by clicking on targets and dragging others for points, i applied the pause script and it works in stopping time but doesn't prevent interactions with the enemies and the point tokens, they can be dragged and removed, all the tutorial talk about pause time but it doesnt' work when my game doesn't use it or the only thing using time are the enemies slowly going toward the center. Tried 2d and 3d sprites, expecting it was a thing related to it but didn't.
Any help you or anyoen can provide, please?
Unbelievable video my friend. Thank you :)
ОтветитьGreat video, how can I do when you unplug the console while playing it automatically stops?
ОтветитьYou definitly need more fame and glory for this My god, you made this so damn easy! <3
ОтветитьThanks for this. It helped me solve the problem of letting a user type into an input field and not have the navigation actions take place if you typed an E or other nav key.
ОтветитьJust found your channel, and looking forward to see more.
ОтветитьLove the video, looking forward to more :)
ОтветитьI was hoping to find a video on scene management. I have scene1 which on a button click uses a function to load scene2. In the OnSceneLoaded, I check if the scenename is Scene2 and if it is , I tried Gameobject.Find to find a text field in my scene to put something into it. But that line of code is dying, getting a NullReferenceException : Object reference not set to an instance of an object" error. How do I make sure the scene is completely loaded, i.e. all gameobjects on it have been instantiated before I try and Find them? Your help would be most appreciated.😀
ОтветитьThis is one of the best tutorials I have seen so far. Easy to understand and concise. Thanks a lot!
ОтветитьAs obvious as it reads(hehe) you can also pause by disabling movement scrips storing vector values, (dont forget about gravity).
Also the way shown in the video is better by any margin of imagination.
I enjoyed this video!
ОтветитьGreat tutorial: simple, clear and has good visualization. Thank you👍
ОтветитьYour tutorials are always well explained and easy to understand. Thank you immensely for your work!!❤️
ОтветитьMy saviour! I didn't know about the unscaled time before and was actually looking for a way to keep UI animations to keep working during a pause.
ОтветитьWas hoping for an alternative
ОтветитьI had just had a similar problem and this is the video that I would have liked to see first.
It has a very good quality, it focuses on explaining the deep instead of the superficial and about the article, the article is INSANE, well explained and looks great.
you gained a spanish speaking subscriber
I just found your channel, I love your content and your way of explaining things. I just watched the Unity events Video and was impressed so I supped and started watching your other videos. continue with this quality and you'll have 500k sups in no time. good luck!
Ответитьpausing games for cats
לא ינום ולא יישן
Thanks for the great video, didn't you swap isPaused = true and false in the last segment. Or I'm not understanding something.
ОтветитьGood video. Only issue is all those public variables in your scripts... 😞
Ответить