Godot Main Menu in 4 Minutes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello hello hello by the end of this tutorial you should be able to make a main menu that you can control either by your mouse or your keyboard our simple menu can start the game go to the options and quit the game for men using godot we want to use the ui node which is already here by default let's rename this node to menu now let's add some children to it we want our menu to be a vertical top down list so we are going to use a vbox container for this now let's add our actual buttons to the v-box container add a button node duplicate that two times by pressing ctrl d let's rename them to start button options button and quit button just to avoid confusion let's also add the respective texts in this window we can position the whole vbox container wherever we want by pressing this layout button in our case we're going to use the bottom left layout because i'm a final fantasy 7 fanboy we can further fine-tune the position of the b-box container by using the margins property at this point we can already test our scene by pressing f6 and we can see that it works but of course the buttons don't do anything yet so let's fix that let's add a script to our menu so we can code what each button does let's go to our start button and go to the notes window look for the signal pressed and connect it to our menu script and now we can code what the button does in this function for the start button we only have to change our scene to the first scene in our game get dot change scene and then paste the string of your first scene in here in my case it's level zero and now it should work now let's go to the options button the way i implemented options in my game is by instancing a scene of the options menu and then adding it as a child of the current node you don't have to do this i don't know how you implement options in your own game i am only doing this as an example finally let's connect the quit button and the code is simply get tree dot quit let's test it by pressing f6 and now it should work but right now we can only control it with our mouse to be able to control it with our keyboard we just have to add a very simple code at the ready function in our script just call grab focus on whichever button you want in this case i'm going to use the start button as our starting point and now we can see that it can be controlled by the keyboard using the default ui input map which are the arrow keys and enter now if you want to get even more fancy the last thing that we have to do is set up our neighbors which basically tells godot which button should be focused next when you press up down left or right let's go to the start button and go to the inspector window and now let's look for the focus tab let's set the neighbor top to be our quit button because if we are on the start button and we press up we want the next button to be the quit button and let's do the opposite for the quit button we want the neighbor bottom to be the start button and now as you can see our menu is looping perfectly at this point we are done but of course i want my main menu to look better than yours so i am going to apply my own theme on it and you can go cry in the corner with your ugly main menu and there we go everything works perfectly if you have any questions join the haramber discord server and you can ask me there yourself or if you want to follow our game polaris join the polaris discord server links in description
Info
Channel: Master Albert
Views: 12,098
Rating: undefined out of 5
Keywords: godot tutorial, godot engine, godot main menu, godot, game development, godot game engine, godot ui, godot ui tutorial, godot main menu tutorial
Id: Mx3iyz8AUAE
Channel Id: undefined
Length: 4min 0sec (240 seconds)
Published: Sat May 22 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.