Тёмный

Tutorial: Pause Menu in Godot 4 

Bramwell
Подписаться 18 тыс.
Просмотров 21 тыс.
50% 1

Venture into the Godot 4 Alpha right now, I cover a bunch of essential skills for creating a pause menu in 3D that'll help you sink your teeth into what's new in the world of Godot
The second alpha release for Godot 4 is here:
godotengine.org/article/dev-s...
Chapters:
00:00 Intro
00:37 UI Containers
03:23 UI Buttons
05:01 Blur Shader
07:28 Open and Close Animation
10:22 The Code!
14:48 Adding the screen to a Player
15:58 Testing it out
16:23 Closing the menu
17:52 Sign off
#Tutorial #Godot4 #GodotEngine
✨ Socials ✨
🐦 Twitter: / bramreth
💬 Discord: / discord
☕ Buy me a coffee: www.buymeacoffee.com/bram
🎮Games: bramwell.itch.io/

Опубликовано:

 

21 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 112   
@jackkinsey
@jackkinsey Год назад
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.
@frozenfridge3943
@frozenfridge3943 Год назад
Gigachad
@idlekrisp
@idlekrisp Год назад
the developer we need, but the developer we dont deserve
@adamgrace726
@adamgrace726 Год назад
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."
@CrowGamesDev
@CrowGamesDev Год назад
@cuppixd4267
@cuppixd4267 Год назад
Saved me, thx
@mys3544
@mys3544 Год назад
MVP
@herrychuzz6393
@herrychuzz6393 10 месяцев назад
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.
@fansot8989
@fansot8989 10 месяцев назад
bro you saved me
@Tehcn_
@Tehcn_ Год назад
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.
@pespsisipper
@pespsisipper Год назад
thx it worked!
@shomeyotubbs
@shomeyotubbs Год назад
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!
@Kwlla
@Kwlla Год назад
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 2 месяца назад
the sliders dont do anything, other than that it helps
@N0THANKY0U
@N0THANKY0U 6 месяцев назад
This might be the best godot tutorial on youtube, you explained everything so clearly and concisely. subbed!
@alexjoneslowkeyontosomething
This was incredibly helpful! Thank you so much for making this
@stucktj
@stucktj Год назад
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.
@ortusleo7367
@ortusleo7367 11 месяцев назад
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!
@lucsteffens
@lucsteffens 2 года назад
Love the escape also "triggered" the button animation in the end!
@WatchNev
@WatchNev Месяц назад
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 7 месяцев назад
you're like the brackeys of godot, very good tutorials
@CarbsCode
@CarbsCode 2 года назад
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:
@mariusbaumann2480
@mariusbaumann2480 2 года назад
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
@AndyAndrewEntertaiment
@AndyAndrewEntertaiment 10 месяцев назад
For anyone not finding the "Size Flags -> Expand" they moved it under "Layout -> Container sizeing -> Expand"
@TheoKregaard
@TheoKregaard 9 месяцев назад
Thanks a lot! :D
@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
@NotSuperSerious
@NotSuperSerious Год назад
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)
@SaiponathGames
@SaiponathGames 2 года назад
Wow, that can be done via Shortcuts too? I never knew about that, nice!
@rafeu2288
@rafeu2288 2 года назад
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
@MistaSmith
@MistaSmith Год назад
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;`
@kulak8548
@kulak8548 Год назад
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()
@Crompwell
@Crompwell Год назад
Any chance we could get a short tutorial on how to get this menu working with gamepad inputs? Pretty please?
@christopheswiderski2026
@christopheswiderski2026 2 года назад
For the algorithm
@BramwellWilliams
@BramwellWilliams 2 года назад
👑
@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)
@H0lley
@H0lley 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 года назад
Good point! Yeah that's a really sad problem - I just want to add glow in 2D! :')
@danielpineda8661
@danielpineda8661 6 месяцев назад
If your wondering where SCREEN_TEXTURE is it is now uniform sampler2D SCREEN_TEXTURE: hint_screen_texture;
@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.
@hidemat5141
@hidemat5141 2 года назад
Cool. Godot 4 looks nice.
@AFE-GmdG
@AFE-GmdG 2 года назад
Nice tutorial. I like the new GD-Script features...
@BramwellWilliams
@BramwellWilliams 2 года назад
Thanks, me too!
@jaypalmer0616
@jaypalmer0616 3 месяца назад
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
@delegalco
@delegalco Год назад
hey i cant seem to get the shader to work can you please help
@Sirmatorz
@Sirmatorz Месяц назад
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.
@triingalxy135
@triingalxy135 5 месяцев назад
it says"expetced data type fo this code:uniform blur: hint_range(0.0, 1.0); how do i fix?
@nyuh
@nyuh 2 года назад
yayyy ui stuff
@BramwellWilliams
@BramwellWilliams 2 года назад
Yasss
@comradecid
@comradecid 6 месяцев назад
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.
@purpletrauma
@purpletrauma 8 месяцев назад
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.
@CosimoDavideViggiano
@CosimoDavideViggiano 9 месяцев назад
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
@owenlloyd2528
@owenlloyd2528 Год назад
Thank you
@fnanfne
@fnanfne 11 месяцев назад
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.
@Cristhian103
@Cristhian103 10 месяцев назад
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#...?
@goranovs
@goranovs 10 месяцев назад
Just wondering why all the demos are lagging on my Rog Laptop :/
@camarada_matt
@camarada_matt 6 месяцев назад
thank you
@wolcamophone4783
@wolcamophone4783 2 года назад
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.
@medhatriad
@medhatriad Год назад
use find_child("whatever") instead
@wolcamophone4783
@wolcamophone4783 Год назад
@@medhatriad Thank you!
@dorktales254
@dorktales254 2 года назад
Godot 4 life
@BramwellWilliams
@BramwellWilliams 2 года назад
💯
@wolcamophone4783
@wolcamophone4783 2 года назад
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
@wolcamophone4783
@wolcamophone4783 2 года назад
WAIT, NVM! It's self.visible = true/false
@cmds.learning7426
@cmds.learning7426 2 года назад
cool!
@firezacerick
@firezacerick Год назад
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 Год назад
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 Год назад
I figured it out. Make sure that your buttons are on a CanvasLayer
@wellhellotherekyle
@wellhellotherekyle Год назад
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 Год назад
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
@wukerplank
@wukerplank Год назад
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 Месяц назад
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.
@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 8 месяцев назад
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 года назад
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:
@bgaming9.
@bgaming9. Год назад
what should i do if there's already an _unhandled_input(event): function in my character?
@ironpickllul
@ironpickllul 9 месяцев назад
just take out _unhandled
@FlampyPants
@FlampyPants Год назад
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 11 месяцев назад
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()
@kaostics-_-
@kaostics-_- Год назад
How do I make those arrow symbols that you use??
@ThaAftrPartie
@ThaAftrPartie Месяц назад
->
@rje613
@rje613 6 месяцев назад
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 6 месяцев назад
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 6 месяцев назад
@@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.
@jarbarsi
@jarbarsi 2 года назад
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 Год назад
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?
@maucazalv903
@maucazalv903 10 месяцев назад
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
@fansot8989
@fansot8989 10 месяцев назад
same
@RexieRacer
@RexieRacer 8 месяцев назад
have you found out how to fix the blur? im having the same problem. EDIT: I fixed it!
@DareChimaera
@DareChimaera 7 месяцев назад
@@RexieRacer You can't just say you fixed it without telling us the fix! What is it???????
@terrytech8812
@terrytech8812 5 месяцев назад
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 2 месяца назад
what about the brigntess slider
@underbikingrules
@underbikingrules 10 месяцев назад
anyone's blur shader not blurring the sky worldenvironment?
@cmdrHeliaxx
@cmdrHeliaxx 9 месяцев назад
happens to me to (to my world environment). Found any fix?
@warrenpaul9858
@warrenpaul9858 10 месяцев назад
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.
@arseniccatnip9040
@arseniccatnip9040 9 месяцев назад
I fixed this myself by adding set_process(false) for the unpause function, and set_process(true) for the pause function :)
@cmdrHeliaxx
@cmdrHeliaxx 9 месяцев назад
@@arseniccatnip9040 Just like that? Doesnt seem to do the trick for me
@cptfurball
@cptfurball 2 года назад
I think there will be more godot 4.0 coming in soon 😂
@BramwellWilliams
@BramwellWilliams 2 года назад
Hell yeah!!
@cptfurball
@cptfurball 2 года назад
@@BramwellWilliams I should make some as well 😂
@spyro2619
@spyro2619 3 месяца назад
16:21 nah you're nice
@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 9 месяцев назад
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")
@metaversegt-official
@metaversegt-official 2 года назад
Nice video ✨ Can we go DM please ? ✨👀
@_Micad
@_Micad 2 месяца назад
get_tree().paused = false does not work anbody know why, same thing with equals true
@2dspaceadventuregame952
@2dspaceadventuregame952 Год назад
Get_tree().paused = true. 18 min video in one sentence.
Далее
The Godot 4 Beta is OUT!
12:44
Просмотров 47 тыс.
Super Easy Pause Menu In Godot 4
16:50
Просмотров 6 тыс.
How to Make a Good 2D Camera
11:38
Просмотров 392 тыс.
This Godot 4 Scene Manager Does it ALL
28:50
Просмотров 22 тыс.
How Games Make VFX (Demonstrated in Godot 4)
5:46
Просмотров 326 тыс.
How To Make Game Art
22:34
Просмотров 187 тыс.
Do THIS Before You Publish Your Godot Game
3:33
Просмотров 153 тыс.
I Made My First Game in Godot in 3 Weeks...
26:21
Просмотров 258 тыс.
How to Add Interaction in Godot 4
16:48
Просмотров 10 тыс.