Tutorial: Pause Menu in Godot 4

Поділитися
Вставка
  • Опубліковано 15 жов 2024

КОМЕНТАРІ • 119

  • @jackkinsey
    @jackkinsey Рік тому +86

    With 4.0 stable out, for anyone following along with this tutorial: the minimum size for the Panel Container is no longer under Rect, but is instead under Layout -> Custom Minimum Size.

  • @herrychuzz6393
    @herrychuzz6393 Рік тому +19

    4:33 Size Flags are under Control > Layout > Container Sizing
    11:30 find_node is find_child now
    The -> arrow is typed just like that.
    Thanks for the tutorial! Works great in my project.

  • @Tehcn_
    @Tehcn_ Рік тому +29

    Quick note for anyone adding this to a pre-existing project: if you use _unhandled_input to control your character/player, your mouse inputs might be blocked. Just use _input instead.
    PS: I'm new to Godot in general, so if there might be a trade-off I don't know about, but this worked for me.

    • @FlasherOfThunder
      @FlasherOfThunder Рік тому

      Worked for me so far, thanks for the tip.

    • @DonLeeelbow667
      @DonLeeelbow667 Рік тому

      Thanks, I just complained about that before seeing this tip.

  • @adamgrace726
    @adamgrace726 Рік тому +35

    To anyone viewing this as of March 10 2023 you will receive an error whilst trying to use SCREEN_TEXTURE.
    "SCREEN_TEXTURE has been removed in favor of using hint_screen_texture with a uniform. To continue with minimal code changes add 'uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;' near the top of your shader."

  • @shomeyotubbs
    @shomeyotubbs Рік тому +1

    Just felt the need to comment and say that this is a wonderful tutorial. I've used to create multiple UI pieces for my game, not just the pause menu. Your use of nesting containers to help keep the UI elements fitted to the screen is brilliant and missing from other tutorials I've seen. Great work!

  • @N0THANKY0U
    @N0THANKY0U 8 місяців тому

    This might be the best godot tutorial on youtube, you explained everything so clearly and concisely. subbed!

  • @AndyAndrewEntertaiment
    @AndyAndrewEntertaiment Рік тому +4

    For anyone not finding the "Size Flags -> Expand" they moved it under "Layout -> Container sizeing -> Expand"

  • @stucktj
    @stucktj Рік тому +1

    This was a very helpful tutorial. In addition to a pause menu, I was able to get a working death and restart menu working from the same concepts shown in this tutorial.

  • @WatchNev
    @WatchNev 3 місяці тому

    I struggled for like 4 hours trying to get my game to `unpause` with a key press and not have to add a button. Finally caved in to look at videos and this made it look extremely easy. With help from all the comments below as well for updated changes.

  • @nipdaboi
    @nipdaboi 10 місяців тому +1

    you're like the brackeys of godot, very good tutorials

  • @ortusleo7367
    @ortusleo7367 Рік тому

    Thank you so much for this tutorial! I just started learning Godot a couple of days ago and I'm finding the lack of assets really difficult to deal with in comparison to something like Unity. This was so helpful and super quick to implement!

  • @NotSuperSerious
    @NotSuperSerious Рік тому +3

    4:13 you can change the font size from the inspector, under "Theme Overrides", in case you don't want to change resolutions
    ... and yes, apparently this bug is still a thing in 4.0.1, unless i'm missing something (very possible)

  • @lucsteffens
    @lucsteffens 2 роки тому +1

    Love the escape also "triggered" the button animation in the end!

  • @rafeu2288
    @rafeu2288 2 роки тому +5

    10:55 You could use `:=` to infer the Node type since it is known at "compile-time".
    It allows to remove duplication of type-hints for either the declarative stuff like the node types, but also works when you initialise from a typed function:
    For example, if I have this function:
    ```
    func give_me_the_answer() -> int:
    return 42
    ```
    Then I can infer the type, so instead of :
    ` var my_answer: int = give_me_the_answer() `
    I can just write, for the exact same benefits:
    ` var my_answer := give_me_the_answer()`
    Hope this is useful for the someone. If you want to search for it, it is called "Type Inference" godot.
    Have a great day :D

  • @CarbsCode
    @CarbsCode 2 роки тому +1

    Lots of little great things in Godot 4 it seems! Love these videos man learn so much in such all at once 😀

    • @BramwellWilliams
      @BramwellWilliams  2 роки тому

      Always lovely to hear from you Carbs! Definitely and glad you liked it c:

  • @H0lley
    @H0lley 2 роки тому +2

    note that the blur background effect can also be achieved without a shader, simply by setting dof_blur_near_enabled of Environment (or CameraEffects in Godot 4).
    unfortunately though, canvas environment/camera effects do not work at all in the current Godot 4 alpha.

    • @BramwellWilliams
      @BramwellWilliams  2 роки тому +1

      Good point! Yeah that's a really sad problem - I just want to add glow in 2D! :')

  • @skulltrick
    @skulltrick 2 роки тому

    This was incredibly helpful! Thank you so much for making this

  • @plasticdinobitch
    @plasticdinobitch Рік тому +14

    6:55 in stable Godot 4.0, SCREEN_TEXTURE has been removed. The way you now do this is adding "uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap;" under the other uniform variables. besides that do everything he does

    • @_Micad
      @_Micad 5 місяців тому +1

      the sliders dont do anything, other than that it helps

  • @MistaSmith
    @MistaSmith Рік тому +4

    6:33 SCREEN_TEXTURE got removed in favor of sth else (I don't get it), but can be added again like this:
    `uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;`

  • @mariusbaumann2480
    @mariusbaumann2480 2 роки тому +1

    great content man! Thanks for doing this stuff, also since shaders are still a form of blackmagic to me I really appreciate the simple explenations for them

  • @kulak8548
    @kulak8548 Рік тому +4

    15:22 Is there really any need to ignore the check for the escape key when pause mode is true? I just put this into the pause menu script and it works fine:
    func _unhandled_input(event: InputEvent) -> void:
    if event.is_action_pressed("pause"):
    if get_tree().paused:
    resume()
    else:
    pause()

  • @medhatriad
    @medhatriad Рік тому

    Thank you for this great tutorial. One tip: for the last part (getting out of the pause menu), you can simply add a togglePause function in your gdscript. This way you can keep all of your logic in the Pause menu and no need to use a shortcut

  • @wolcamophone4783
    @wolcamophone4783 2 роки тому +4

    find_node("whatever") doesn't seem to want to work in alpha 11, returns "Function "find_node()" not found in base self." You can right click and copy the path to the node manually to paste into the string for get_node("marg/box/whatever") which documentation says is faster anyway.

  • @purpletrauma
    @purpletrauma 11 місяців тому

    After reaching the end, and even swapping the pause effect with one I wanted more than the blur shader... I successfully learned the tutorial I used for the player control was incompatible with this code. I think it has something to do with mouse look input also being in "unhandled_event". Or the fact that a find_node function does not appear to be within Godot 4.1.3 Stable. May start again from the top with your tutorials; his work, as much as it felt good to follow the tutorials, is more geared towards an FPS project.

  • @danielpineda8661
    @danielpineda8661 9 місяців тому +1

    If your wondering where SCREEN_TEXTURE is it is now uniform sampler2D SCREEN_TEXTURE: hint_screen_texture;

  • @Crompwell
    @Crompwell Рік тому +1

    Any chance we could get a short tutorial on how to get this menu working with gamepad inputs? Pretty please?

  • @CosimoDavideViggiano
    @CosimoDavideViggiano Рік тому

    for the shortcut: why you don't use the _input(event) function?
    In my project I wrote in the script:
    func _input(event):
    if Input.is_action_just_pressed("pause"):
    if get_tree().paused:
    unpause()
    else:
    pause()
    In this way you don't have to navigate in menus and sub menus of components

  • @wukerplank
    @wukerplank 2 роки тому +3

    I'm trying to use this in a project where the mouse is captured and now my mouse movents get swallowed... How do I get around this?

    • @ThaAftrPartie
      @ThaAftrPartie 3 місяці тому

      I know I’m late,
      but In the func,
      change “CAPTURED”: in
      “MOUSE_MODE_CAPTURED”
      To
      “VISIBLE”
      If you don’t want it consumed by the client.

  • @wellhellotherekyle
    @wellhellotherekyle 2 роки тому +3

    The menu seems to work properly but when I added it to my FPS controller from your other tutorial now I can't turn around (though my movement keys still work). Any idea what's going on?
    PS.... Am I missing something or is the handy font size feature at the top gone now?

    • @alvhawk4461
      @alvhawk4461 Рік тому +1

      the font size feature at the top is gone but for label i found a label settings thing under where u put text and if u add it in u can change line spacing, font size, font color, outline, and shadow
      buttons is in theme overrides i think
      idk how to fix ur turning around issue tho sry

    • @gazz1617
      @gazz1617 Рік тому

      @@alvhawk4461 Thank you! I was really scratching my head with where the font sizes moved to, LabelSettings look really nice

  • @comradecid
    @comradecid 9 місяців тому

    fyi - i ran into an issue whilst attempting to 'adjust' the unpause animation; i wanted the menu to fade-out more gracefully, and so disabled its autoplay-on-load setting, instead triggering the unpause only when the player exited the menu. i soon discovered that regardless of the settings/overrides i attempted to apply to the menu, it was always visible by default. the animations continued to work correctly (it would fade in and out as expected), but try as i might, i couldn't get the bloody thing to be hidden by default.
    only then did i finally realise that it required the use of a default animation state; b y duplicating my existing unpause animation, i created a third animation called 'hidden', which executed a hide in the shortest possible timeframe. i then set this to autoplay-on-load, and continued to apply my slower unpause animation programmatically when the user triggered ui_cancel. after a fair amount of cursing, it worked like a charm.

  • @fnanfne
    @fnanfne Рік тому

    Great tutorial! I've learned so much about stuff I use all the time. I could never get the "duplicate" to do anything in the AnimationPlayer, now it's like facepalm, ta! I see so many comments about things that changed in godot. This is soooooo frustrating, why on earth do they keep on changing things like this? Not cool. Anyhoo, what happened to "find_node()"?? I can't even see any documentation on its disappearance, do we need to use find_child() instead? OOF.

  • @SaiponathGames
    @SaiponathGames 2 роки тому +1

    Wow, that can be done via Shortcuts too? I never knew about that, nice!

  • @b4ttlemast0r
    @b4ttlemast0r 9 днів тому

    i just put in the menu script (i created an input action called "pause"):
    func _input(event: InputEvent) -> void:
    if event.is_action_pressed("pause"):
    if get_tree().paused:
    unpause()
    else:
    pause()

  • @firezacerick
    @firezacerick Рік тому +3

    For some reason, when I made the start menu it is pausing also the buttons, even with the mode seted to aways. Can anyone help me?

    • @deathfxu
      @deathfxu Рік тому +4

      I am having this same issue! My buttons seem paused. They aren't getting mouse hover or click events. I have been trying to solve this problem for several days. Please help!

    • @deathfxu
      @deathfxu Рік тому +3

      I figured it out. Make sure that your buttons are on a CanvasLayer

  • @jarbarsi
    @jarbarsi 2 роки тому +3

    I feel like you overcomplicated the pausing code a bit, if it was me I would've just used _input(event) or _unhandled_input(event) in the pause menu script and toggled the pausing from there just to keep everything in one place
    func _unhandled_input(event):
    if event.is_action_just_pressed("ui_cancel"):
    if get_tree().paused:
    unpause()
    else:
    pause()
    (also youtube comments really need code blocks....youtube comments really need a lot of things)

    • @BramwellWilliams
      @BramwellWilliams  2 роки тому

      Totally valid! I just really like shortcuts and in my experience it isn't quite ideal using whether the tree is paused as a source of truth as then you can't pause in multiple ways, say for opening an inventory as well as a general pause menu.
      Also really wish it supported code blocks, then i could dump useful stuff in descriptions and pinned comments too :(

    • @eliyahumedia
      @eliyahumedia Рік тому +1

      I tried what you wrote and put it in the pausemenu script but now the look around function of my FPSController does not work. do you know what is causing it and how to fix it?

  • @christopheswiderski2026
    @christopheswiderski2026 2 роки тому +7

    For the algorithm

  • @rje613
    @rje613 9 місяців тому +1

    This doesn't work in Godot anymore, even with the fix for SCREEN_TEXTURE. For some reason the blur doesn't affect 3D scenes. Anyone else had the same experience?

    • @kpickett9128
      @kpickett9128 9 місяців тому

      for me the blur was there but it was very subtle for some reason, so i ended up cranking up the blur slider max value in the shader to .75 to make it more obvious...
      but i'm in a 2D scene, using Godot 4.1.3, so might be unrelated to the issue you're seeing if that issue is unique to 3D scenes or a different version : (

    • @rje613
      @rje613 9 місяців тому +1

      @@kpickett9128 I think I ended up finding a fix for it. The first issue was that there has to be objects beyond the scene. As in, if you literally just have a cube in a blank scene, even with a light and an environment, it wouldn't work because it couldn't blur the edges of the cube "into" anything, so to speak. Also, objects that clip into the sky wouldn't blue. Very odd!
      The second issue was related to SSR (screen-space reflections). For some reason, having that enabled in scene world settings caused weird artifacts, and also prevented the blur from working entirely.
      In the end, I settled for using a gausian filter instead. The built-in textureLOD function was just way too temperamental and I wanted something more permanent and less fiddly.

  • @efhunter
    @efhunter Рік тому

    Really nicely edited tutorial!
    What should I do if my (2D top down) player isn't always in the center of the screen? (The pause menu pops up centered on the player's position, instead of being centered based on the screen itself)

  • @wolcamophone4783
    @wolcamophone4783 2 роки тому +1

    I've decided I don't wanna use the animation, so I usually just toggle the whole node visibility in code, but self.visible(true/false) and self.show/self.hide don't seem to work anymore, at least not for the Control node

  • @FlampyPants
    @FlampyPants Рік тому +2

    If I hit resume and the pause menu closes I can still hit the quit button even after the pause menu closes, which closes the game

    • @fnanfne
      @fnanfne Рік тому

      Add the following to the func _ready()
      $ColorRect/CenterContainer.hide()
      Add the following to the func unpause()
      $ColorRect/CenterContainer.hide()
      Add the following to the func pause()
      $ColorRect/CenterContainer.show()

  • @triingalxy135
    @triingalxy135 8 місяців тому

    it says"expetced data type fo this code:uniform blur: hint_range(0.0, 1.0); how do i fix?

  • @terrytech8812
    @terrytech8812 8 місяців тому +1

    This videos shader was not working for me and after some Chat GPT i got this masterpeace, Be sure to change the shadder parameters to around 0.002
    shader_type canvas_item;
    uniform sampler2D screen_texture : hint_screen_texture;
    uniform vec2 blur_size;
    void fragment() {
    vec4 color = vec4(0.0);
    int count = 0;
    for(int i=-2; i

    • @_Micad
      @_Micad 5 місяців тому +1

      what about the brigntess slider

  • @dorktales254
    @dorktales254 2 роки тому +6

    Godot 4 life

  • @nyuh
    @nyuh 2 роки тому +1

    yayyy ui stuff

  • @jaypalmer0616
    @jaypalmer0616 6 місяців тому

    I'm so close to getting this working, I used your fps controller tutorial and slapped the two together, but the issue is that the mouse no longer controls the camera and i don't know why

  • @SimonCrenshaw
    @SimonCrenshaw Місяць тому

    This Tutorial almost no longer works. The pause menu doesn't show, but functions if it did, and it locks the mouse movement. Although, I'm not sure if this is because of my player layout.

  • @Cristhian103
    @Cristhian103 Рік тому

    How reliable and safe is it to develop a professional 2d game with Godot and c#? The documentation I find is not complete and details are missing on how to correctly use Godot with c#. Do you have courses to offer with godot and c#...?

  • @AFE-GmdG
    @AFE-GmdG 2 роки тому

    Nice tutorial. I like the new GD-Script features...

  • @Sirmatorz
    @Sirmatorz 4 місяці тому

    I'm having an issue with this tutorial in 4.2.2.stable where the UI is just tiny and on the side of the screen and i can't get it to be big and in the center and if i do stick it to my character i lose the ability to move my camera since it overrides my mouse input with the control node...
    I can't seem to find how to fix this so if anyone has a similar issue some help would be greatly aprreciated , thanks lads.

  • @Betegfos
    @Betegfos Рік тому

    I receive the following error in the _ready function in Beta 10: Invalid type in function 'connect' in base 'Signal'. Cannot convert argument 1 from Nil to Callable.

  • @warrenpaul9858
    @warrenpaul9858 Рік тому

    The issue I had which took me a little bit to find was clicking my left mouse button I thought would crash the game. I realized that the menu is always technically there, just invisible, so I was actually clicking quit every time I left clicked.

    • @hightekHextress
      @hightekHextress Рік тому

      I fixed this myself by adding set_process(false) for the unpause function, and set_process(true) for the pause function :)

    • @cmdrHeliaxx
      @cmdrHeliaxx Рік тому

      @@hightekHextress Just like that? Doesnt seem to do the trick for me

  • @goranovs
    @goranovs Рік тому

    Just wondering why all the demos are lagging on my Rog Laptop :/

  • @owenlloyd2528
    @owenlloyd2528 Рік тому

    Thank you

  • @MixedSourceStudio
    @MixedSourceStudio 2 місяці тому

    at 7:20 when i set my brightness to 1 the background is all White.... what am i doing wrong?

    • @MixedSourceStudio
      @MixedSourceStudio 2 місяці тому

      I fixed it needed to add
      uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
      But had added:
      uniform sampler2D SCREEN_TEXTURE ;

  • @SimonCrenshaw
    @SimonCrenshaw Місяць тому

    find_node doesn't work, but the find_child fixed the error.

  • @hidemat5141
    @hidemat5141 2 роки тому

    Cool. Godot 4 looks nice.

  • @kaostics-_-
    @kaostics-_- Рік тому +1

    How do I make those arrow symbols that you use??

  • @bgaming9.
    @bgaming9. Рік тому

    what should i do if there's already an _unhandled_input(event): function in my character?

  • @maucazalv903
    @maucazalv903 Рік тому

    1. 3:46 they changed it....
    where can I see it?
    2. I followed the tutorial but there are 2 issues: 1) for some reason it keeps on the blur effect even after pressing resume, I check the keyframaes and blur is on 0 on the unpause animation so idk what´s causing that 2) for some reason after resume the mouse inputs don´t register until a few seconds later... its like it lags

    • @fansot0592
      @fansot0592 Рік тому +1

      same

    • @RexieRacer
      @RexieRacer 11 місяців тому +1

      have you found out how to fix the blur? im having the same problem. EDIT: I fixed it!

    • @DareChimera
      @DareChimera 10 місяців тому

      @@RexieRacer You can't just say you fixed it without telling us the fix! What is it???????

  • @cyphfrix1620
    @cyphfrix1620 Рік тому

    when making the shader i got an error, i did what the comments told me to do but it didnt work and i got a new error and it said Expected expression, found: 'UNIFORM' what do i do

    • @RexieRacer
      @RexieRacer 11 місяців тому

      is uniform in caps?

  • @Kio_Kurashi
    @Kio_Kurashi 2 роки тому

    Now I wonder what I would need to do to make sure things aren't clickable behind a window if I were to add in something like a settings menu that is called from here. (or in the way this works: Is "revealed")

    • @BramwellWilliams
      @BramwellWilliams  2 роки тому +2

      Control nodes have a mouse property! if you set mouse mode to ignore the mouse can click things underneath, stop will stop clicks going through c:

  • @delegalco
    @delegalco Рік тому

    hey i cant seem to get the shader to work can you please help

  • @cptfurball
    @cptfurball 2 роки тому +2

    I think there will be more godot 4.0 coming in soon 😂

  • @cmds.learning7426
    @cmds.learning7426 2 роки тому

    cool!

  • @underbikingrules
    @underbikingrules Рік тому

    anyone's blur shader not blurring the sky worldenvironment?

    • @cmdrHeliaxx
      @cmdrHeliaxx Рік тому

      happens to me to (to my world environment). Found any fix?

  • @spyro2619
    @spyro2619 6 місяців тому

    16:21 nah you're nice

  • @otto2853
    @otto2853 16 днів тому

    They removed "find_node"

  • @alvhawk4461
    @alvhawk4461 Рік тому

    damn this broke like everything in my code and ive spent hours trying to fix it but idk
    ima just not do this and make escape quit the game

  • @ironhandstudio6612
    @ironhandstudio6612 Рік тому

    var likeit; likeit = false; var loveit = true whatever!

  • @rgstudio7272
    @rgstudio7272 2 роки тому

    with the newer alpha go with @onready var first_button : Button = get_node("CenterContainer/PanelContainer/MarginContainer/VBoxContainer/ResumeButton")

  • @TheGl1tchMast3r
    @TheGl1tchMast3r 21 день тому

    I don't know how quick someone will respond to this, but i'm having some trouble with this code. Firstly, the buttons seem to work fine in the PLAYER scene, however as soon as i test it in the main game scene the buttons do not work. Secondly, within the player scene when the buttons do work, i've added a third button that takes you back to the main menu, however after pressing it none of the scripts within the main menu scene seem to work. code for this is underneath
    func _on_quit_to_menu_pressed():
    get_tree().change_scene_to_packed(menu)
    apart from these bugs this has been an overall great video, just hope i or someone else can figure what the hell is going on lol.

    • @TheGl1tchMast3r
      @TheGl1tchMast3r 21 день тому

      there has also been a variable added for qutting to the menu
      @onready var quit_to_menu: Button = $"CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Quit to Menu"

  • @metaversegt-official
    @metaversegt-official 2 роки тому

    Nice video ✨ Can we go DM please ? ✨👀

  • @_Micad
    @_Micad 5 місяців тому +1

    get_tree().paused = false does not work anbody know why, same thing with equals true

  • @2dspaceadventuregame952
    @2dspaceadventuregame952 Рік тому +1

    Get_tree().paused = true. 18 min video in one sentence.

  • @camarada_matt
    @camarada_matt 9 місяців тому

    thank you