How to Simple Pause In Unity

How to Simple Pause In Unity

Umbriel

1 год назад

20 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@lln6123
@lln6123 - 01.01.2024 23:46

Very well explained!!

Ответить
@thescotster19
@thescotster19 - 27.12.2023 16:08

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.

Ответить
@NorinDev
@NorinDev - 06.12.2023 15:52

very nice video:)

Ответить
@OrkhanJulfa
@OrkhanJulfa - 01.12.2023 11:19

Thank you very much! Great tutorial!

Ответить
@watercat1248
@watercat1248 - 24.11.2023 12:13

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

Ответить
@byram_brt
@byram_brt - 29.10.2023 21:30

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

Ответить
@crazyone3494
@crazyone3494 - 26.10.2023 09:03

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?

Ответить
@ourinterface7077
@ourinterface7077 - 04.09.2023 04:57

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.

Ответить
@vasileiospgr
@vasileiospgr - 19.08.2023 21:26

niceeee! 🖤

Ответить
@Ella_Kitcat.71GFbleny
@Ella_Kitcat.71GFbleny - 07.08.2023 02:24

OK dude

Ответить
@Blinkers2007GameDev
@Blinkers2007GameDev - 04.08.2023 18:01

Need to pause the game whenever interacting with npc:s to actually be able to use mouse to answer NPC. Helpful tutorial, thank you.

Ответить
@omerlikos2549
@omerlikos2549 - 04.07.2023 16:44

this is quality stuff. dont stop giving us such amazing content.

Ответить
@rahmadhadi464
@rahmadhadi464 - 27.06.2023 17:15

Good work bro

Ответить
@alexandrusirbu3083
@alexandrusirbu3083 - 27.06.2023 14:38

This is a good quality video that solved my problem. Great job !

Ответить
@saitakman5622
@saitakman5622 - 26.06.2023 13:36

I read your blog about pause a game.Amazing blogpost to answer almost every question.Thank you

Ответить
@halfbakedproductions7887
@halfbakedproductions7887 - 04.06.2023 21:15

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.

Ответить
@sourisgogo
@sourisgogo - 06.05.2023 23:53

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.

Ответить
@joshduffety-wong9618
@joshduffety-wong9618 - 03.05.2023 13:43

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.

Ответить
@mattsithknight1530
@mattsithknight1530 - 19.04.2023 17:29

Amazing video, love how you explain everything and show different examples. Now to watch all your other vids.

Ответить
@happypixls
@happypixls - 18.04.2023 16:46

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.

Ответить
@calebhorton3689
@calebhorton3689 - 17.03.2023 18:51

Very helpful! Thanks for the video

Ответить
@dykycoend3302
@dykycoend3302 - 28.02.2023 03:41

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.

Ответить
@user-tq7bd7jb3m
@user-tq7bd7jb3m - 19.02.2023 06:59

for some reason my fps goes to -2e+09 when the game pauses why is that?

Ответить
@stephenbeaty1221
@stephenbeaty1221 - 31.01.2023 22:38

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!

Ответить
@firingpin3520
@firingpin3520 - 12.01.2023 09:31

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!

Ответить
@toadmaster
@toadmaster - 20.12.2022 16:41

Incredible tutorial, completely surpassed my expectations on this one! Thanks a lot for the help

Ответить
@jeanmestti6195
@jeanmestti6195 - 04.12.2022 12:15

way too good ma boy!

Ответить
@BlueGooGames
@BlueGooGames - 03.12.2022 13:13

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!

Ответить
@armm6437
@armm6437 - 24.11.2022 17:09

Thank you for much. It's really very useful information

Ответить
@doarner
@doarner - 18.11.2022 20:14

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?

Ответить
@ryanem969
@ryanem969 - 16.11.2022 01:16

Unbelievable video my friend. Thank you :)

Ответить
@faisalalhaddad5537
@faisalalhaddad5537 - 05.11.2022 20:05

Great video, how can I do when you unplug the console while playing it automatically stops?

Ответить
@DashingduoGaming
@DashingduoGaming - 18.10.2022 16:47

You definitly need more fame and glory for this My god, you made this so damn easy! <3

Ответить
@jeff_holmes
@jeff_holmes - 17.10.2022 06:56

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.

Ответить
@random_precision_software
@random_precision_software - 12.10.2022 20:33

Just found your channel, and looking forward to see more.

Ответить
@thed100mechanic
@thed100mechanic - 18.09.2022 21:32

Love the video, looking forward to more :)

Ответить
@macleodgordon
@macleodgordon - 26.08.2022 00:09

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.😀

Ответить
@indieforger2654
@indieforger2654 - 18.08.2022 11:20

This is one of the best tutorials I have seen so far. Easy to understand and concise. Thanks a lot!

Ответить
@gekkek2005
@gekkek2005 - 12.08.2022 13:42

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.

Ответить
@blades575
@blades575 - 07.08.2022 20:11

I enjoyed this video!

Ответить
@rostyslavsmetanin3415
@rostyslavsmetanin3415 - 07.08.2022 14:35

Great tutorial: simple, clear and has good visualization. Thank you👍

Ответить
@innefuble
@innefuble - 06.08.2022 16:19

Your tutorials are always well explained and easy to understand. Thank you immensely for your work!!❤️

Ответить
@LoldemortII
@LoldemortII - 06.08.2022 14:43

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.

Ответить
@DevDunkStudio
@DevDunkStudio - 06.08.2022 02:47

Was hoping for an alternative

Ответить
@JimSegovia
@JimSegovia - 04.08.2022 07:11

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

Ответить
@yasseraltamimi6171
@yasseraltamimi6171 - 01.08.2022 05:57

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!

Ответить
@EnderElohim
@EnderElohim - 01.08.2022 04:08

pausing games for cats
לא ינום ולא יישן

Ответить
@user-oi3kp7hh1n
@user-oi3kp7hh1n - 01.08.2022 00:27

Thanks for the great video, didn't you swap isPaused = true and false in the last segment. Or I'm not understanding something.

Ответить
@Vastlee
@Vastlee - 31.07.2022 23:05

Good video. Only issue is all those public variables in your scripts... 😞

Ответить