How To Make a Topdown RPG in Godot 4: Adding Menus! (Part 3)

DuoTutor / DoisTutor
28 May 202314:06

Summary

TLDRThis video tutorial guides viewers through creating a settings menu in a game development environment using Godot. It covers the process of organizing audio files, setting up folders, and constructing a user interface with various containers and elements like checkboxes, sliders, and buttons. The script also demonstrates how to implement audio and video settings adjustments, including volume control and full-screen toggles, and concludes with saving and testing the menu.

Takeaways

  • ๐Ÿ“ Start by organizing files: Create folders named 'audio' and 'menus' for structured project management.
  • ๐ŸŽต Import audio files: Bring in a 'toggle' sound and a 'wind' sound to be used for music toggles in the project.
  • ๐Ÿ› ๏ธ Set up UI elements: Construct a pop-up panel with nested containers (VBox, Panel, Margin, HBox) and a checkbox for 'fullscreen'.
  • ๐Ÿ”Š Manage audio settings: Duplicate and rename panel containers to 'sound settings' and 'video settings', adjusting UI components accordingly.
  • ๐Ÿ”‘ Utilize sliders: Add sliders for 'game slider' and 'music slider' to control audio levels, using a horizontal orientation.
  • ๐ŸŽ›๏ธ Implement audio streaming: Add 'AudioStreamPlayer' nodes for sound effects and music, and configure them with respective buses.
  • ๐Ÿ”ˆ Adjust audio buses: Create and assign buses for 'music' and 'sound effects' to manage different audio types separately.
  • ๐Ÿ“ Script interactions: Write scripts for adjusting volume based on slider values and toggling fullscreen mode.
  • ๐Ÿ”— Connect UI to functionality: Ensure sliders and checkboxes are connected to the correct script functions for immediate feedback.
  • ๐ŸŽฎ Create a main menu: Design a main menu with buttons for 'play', 'settings', and 'quit', and ensure the pop-up panel is initialized as invisible.
  • ๐Ÿ”„ Test and iterate: After setting up, test the in-game audio and video settings to ensure they function as intended and make adjustments if necessary.

Q & A

  • What is the first step in creating the audio and menus folders in the script?

    -The first step is to create a new folder named 'audio' and another one named 'menus'.

  • Which two sounds are imported for the audio in the script?

    -A toggle sound and a wind sound are imported for the audio.

  • What kind of panel is created first in the script, and what is its purpose?

    -A pop-up panel is created first, which is used to create settings for sound and video.

  • How are the containers structured within the pop-up panel?

    -The containers are structured as follows: a VBox container, a Panel container, a Margin container, an HBox container, and finally a CheckBox.

  • What is the purpose of duplicating the panel container in the script?

    -The panel container is duplicated to create separate sections for 'sound settings' and 'video settings'.

  • How are the sliders named after being duplicated?

    -The sliders are renamed to 'game slider' and 'music slider' after duplication.

  • What does the 'normal audio stream player' do in the script?

    -The 'normal audio stream player' is used to play sound effects and music, with instances named 'sound effects' and 'music'.

  • What are the two buses added in the audio settings, and what are they used for?

    -Two buses are added, one for 'music' and one for 'sound effects', used to manage the volume of these audio types.

  • How are the volume levels of the sound effects and music adjusted in the script?

    -The volume levels are adjusted using the 'game slider' and 'music slider' connected to the respective audio buses.

  • What is the purpose of the 'done' button in the script?

    -The 'done' button is used to close the pop-up settings panel.

  • How is the main menu created and what elements does it contain?

    -The main menu is created with a Control node, a Margin container, a Panel, and nested VBoxes containing labels for the game title and buttons for 'play', 'settings', and 'quit'.

  • What script functionality is added to the play, settings, and quit buttons in the main menu?

    -The play button changes the scene to 'world', the settings button opens the settings panel, and the quit button closes the application.

Outlines

00:00

๐ŸŽฎ Game Settings UI Creation

The paragraph describes the process of setting up a user interface for game settings in a development environment. It begins with creating folders for audio and menus. Audio files such as toggle sound and wind sound are imported. A pop-up panel is created with various container elements like vbox, panel, margin, and hbox containers. A checkbox for full-screen is added and duplicated to create sound and video settings sections. The paragraph details the renaming of containers, the addition of sliders for game and music volume, and the implementation of audio stream players for sound effects and music. Buses for music and sound effects are added in the audio settings, and the scene is saved as a pop-up menu.

05:05

๐Ÿ”Š Audio and Video Settings Scripting

This paragraph focuses on scripting for the previously created settings UI. It involves adding scripts to the sound and video settings sections. The script initializes export variables for sound effect and music audio names. It also sets up honorary variables and connects sliders to their respective settings. The paragraph explains how to adjust the volume based on the slider values and handle bus muting. It also covers the scripting for a full-screen toggle checkbox and a done button to close the settings panel. The paragraph concludes with the creation of a main menu with a title, buttons for play, settings, and quit, and the instantiation of the pop-up panel with its visibility set to off.

10:06

๐ŸŽจ Finalizing Game Menu and Audio Setup

The final paragraph details the process of finalizing the main menu and audio setup. It involves saving the main menu scene and adjusting the visibility of UI elements. A new script is created for the main menu, which includes functions for button presses that handle scene changes, open settings, and quit the game. The paragraph also covers the addition of sound effects and music to the audio setup, adjusting bus names, and setting volume levels. The video concludes with a demonstration of the settings in action and a prompt for viewer engagement through likes and comments.

Mindmap

Keywords

๐Ÿ’กFolder

In the context of the video, a 'folder' refers to a virtual container used to organize files and other folders within a file system. The script mentions creating folders named 'audio' and 'menus' to categorize and manage the project's assets, which is a common practice in digital content management to keep the workspace organized and efficient.

๐Ÿ’กAudio

The term 'audio' in the video script pertains to sound files that are imported and used in the project. Audio files like 'toggle sound' and 'wind sound' are mentioned, which are essential for creating interactive and immersive experiences. These audio files are managed within the 'audio' folder and are utilized in the game's sound settings.

๐Ÿ’กPop-up Panel

A 'pop-up panel' is a UI (User Interface) element that appears on top of the main screen, typically to provide additional information or options without leaving the current screen. In the video, creating a pop-up panel is part of setting up the game's settings menu, allowing users to adjust audio and video preferences.

๐Ÿ’กContainer

In the video, 'container' refers to various UI elements like VBox, HBox, and Panel that are used to organize and layout other UI components. Containers help in structuring the user interface by grouping related elements together, which is crucial for creating a functional and aesthetically pleasing layout.

๐Ÿ’กSlider

A 'slider' is a UI control that allows users to select a value from a range by moving a handle along a track. In the script, sliders are used for the 'game slider' and 'music slider' to adjust the volume levels of game sound effects and music, respectively. This provides a visual and interactive way for users to control audio settings.

๐Ÿ’กAudio Stream Player

An 'audio stream player' is a component that plays audio streams in a game or application. The script mentions adding 'normal audio stream players' and duplicating them to create 'sound effects' and 'music' players. These players are used to manage and control the playback of different audio types within the game.

๐Ÿ’กBus

In the context of the video, a 'bus' refers to an audio bus, which is a routing path for audio signals in a mixing console or audio software. The script describes adding buses for 'music' and 'sound effects' to manage and control the audio output channels separately, allowing for independent volume adjustments and effects processing.

๐Ÿ’กScript

A 'script' in the video refers to a piece of code that is written to define the behavior of UI elements and other game components. The script mentions adding scripts to 'sound settings' and 'video settings' to handle user interactions and apply changes, such as adjusting volume levels and toggling fullscreen mode.

๐Ÿ’กCheckBox

A 'check box' is a UI element that allows users to select or deselect an option. In the video, a check box is used for the 'full screen' toggle, providing a visual and interactive way for users to enable or disable fullscreen mode in the game settings.

๐Ÿ’กMargin Container

A 'margin container' is a UI element that adds space around its child elements, helping to position and organize them within the interface. The script mentions adding a margin container to the main menu to ensure that the elements are not cluttered and are visually appealing.

๐Ÿ’กButton

A 'button' in the video is a UI element that users can click to trigger actions or events. The script describes adding buttons like 'play', 'settings', and 'quit' to the main menu, which are essential for navigating the game and accessing different features.

Highlights

Creating a new folder named 'audio' and another named 'menus'.

Importing a toggle sound and a wind sound for music toggles.

Creating a pop-up panel with a series of nested containers for settings.

Adding a full-screen toggle checkbox.

Duplicating panel containers for sound and video settings.

Renaming containers and removing unnecessary elements.

Adding sliders for game and music volume control.

Adding an AudioStreamPlayer for sound effects and music.

Creating audio buses for sound effects and music.

Saving the scene as 'pop-up menu' under the 'menus' folder.

Adding scripts to manage sound and video settings.

Initializing export variables for sound and music audio names.

Connecting sliders to settings panels for real-time volume control.

Setting up a full-screen toggle in the video settings script.

Adding a 'Done' button to close the settings pop-up.

Creating a 'main menu' scene with title, buttons, and pop-up panel instantiation.

Adding scripts to handle button presses for play, settings, and quit functions.

Setting the main menu as the project's main scene.

Adding sound effect and music to their respective buses in the settings.

Adjusting volume levels for sound effects and music.

Testing the settings panel and main menu functionality.

Invitation for feedback and engagement with a prompt for likes and comments.

Transcripts

play00:01

foreign

play00:13

to begin let's create a new folder

play00:16

and we'll call this one audio

play00:20

then we'll create another folder and it

play00:22

will be called menus

play00:24

now for our audio I've imported a toggle

play00:27

sound

play00:30

and I also imported a wind sound

play00:34

which will be used for our Music toggles

play00:39

we will first create a pop-up panel

play00:45

then we will add a vbox container

play00:49

then we will add a panel container

play00:55

then we will add a margin container

play00:58

then we'll add an hbox container

play01:02

and then it will add a check box

play01:08

we can just put in the text as full

play01:11

screen

play01:15

and then we can go on to duplicate

play01:19

this panel container here

play01:22

and we will rename this one to sound

play01:25

settings

play01:27

and then this one

play01:29

to video settings

play01:31

Oh wrong one

play01:39

and then remove the check box here

play01:43

create change type

play01:46

into a vbox container

play01:52

I did so by right clicking and then

play01:55

going under the rename to change type

play01:59

and then we will add a label

play02:04

then we will add a slider

play02:08

for this one I'm using a horizontal

play02:10

slider

play02:12

and then we can duplicate these

play02:15

so I've renamed these to game slider and

play02:18

music slider

play02:20

then what we'll want to do is add a

play02:23

normal audio stream player

play02:26

and duplicate it

play02:28

name this one to sound effects

play02:30

and name this one to music

play02:34

we will then go to audio then add a bus

play02:37

then add another bus

play02:40

this one will be our music

play02:43

and this one will be our sound effects

play02:49

save the scene under menus

play02:53

and save it as pop-up menu

play03:02

next what we'll want to do is go into

play03:04

sound settings and then add a new script

play03:08

and then we will want to go to video

play03:10

settings and add a new script as well

play03:17

after doing so we'll want to make sure

play03:19

that we have our game slider

play03:22

go into node

play03:24

and then we will double click on value

play03:26

change

play03:27

and it will connect to the sound

play03:29

settings

play03:31

then under music slider

play03:33

will go on value change as well for the

play03:35

node and then we'll connect to sound

play03:37

settings

play03:39

so what we'll want to do first is just

play03:42

remove

play03:43

this over here

play03:45

then we will initialize some export

play03:48

variables this will be sound effect

play03:50

audio name

play03:53

it'll be

play03:54

colon string equal to a string

play04:00

we can just copy and paste this

play04:03

and instead we'll have music audio

play04:08

name

play04:11

then we'll initialize some honorary

play04:13

variables on ready VAR sound effect

play04:15

player

play04:18

is equal to and I'll just copy and paste

play04:23

this

play04:25

what you can do though is go to your

play04:29

your wanted node and then you can right

play04:32

click on it

play04:33

and around here you'll be able to go

play04:35

down and copy node path or you can also

play04:39

do control shift C to control or to get

play04:42

the path

play04:46

then we'll get our music player

play04:54

then we'll get our slider so we'll get

play04:57

our

play04:59

game slider for the game sound effects

play05:05

and then we will get our music slider

play05:17

after doing so we can go down to our

play05:20

first function type variable audio index

play05:24

is equal to audio server

play05:27

dot get bus

play05:29

index

play05:32

and then we'll put our sound effect

play05:34

audio name

play05:36

next we'll do if value is greater than

play05:39

game slider

play05:42

dot Min value

play05:45

then we will set our volume

play05:48

decibel

play05:51

as linear to

play05:54

decibel of our value

play05:59

and then we'll have the audio server

play06:01

get the if the bus mute so if it is

play06:06

muted or not

play06:07

and then we'll get our audio index and

play06:10

then we'll put in false as our Bool

play06:13

then we'll put audio server dot set bus

play06:17

volume

play06:19

decibel

play06:20

and then audio index

play06:24

then volume decibel

play06:27

then for our else statement

play06:29

we're going to set this part

play06:33

to true

play06:34

as the value of the slider is less than

play06:37

the minimum so that means it is muted

play06:41

then for a sound effects player we'll

play06:43

just play the audio

play06:47

down here we could copy and paste this

play06:49

all over here

play06:53

but instead we will change this to music

play06:56

player instead

play07:01

and then it will also set

play07:04

our music slider here instead of our

play07:08

game slider

play07:10

next we'll want to go over to our check

play07:12

box then go to toggled double click it

play07:17

and then connect it to video settings

play07:20

we can remove all this

play07:22

and then we can do the following

play07:26

if button pressed

play07:29

since this is a bull we can set that

play07:33

then display server that window set mode

play07:37

display server dot Window mode full

play07:42

screen be sure that this is all

play07:44

capitalized here

play07:47

and then else

play07:49

we can copy and paste this but instead

play07:52

we will set this to window

play07:56

mode windowed

play08:02

and finally we will just add a done

play08:05

button

play08:06

so under the vbox container we will add

play08:09

a button

play08:11

and under the inspector we can just type

play08:14

done for the text

play08:16

and then we'll create a script for our

play08:18

pop-up panel

play08:22

remove all this

play08:24

and then we can go under our button

play08:26

click on node and then click on pressed

play08:32

and then under the script here we will

play08:34

type visible is equal to false

play08:41

we will then add in

play08:43

our ready function

play08:45

and then we'll automatically set visible

play08:48

equal to false

play08:52

just in case if there's usually a bug

play08:54

associated with this but it will

play08:56

sometimes activate the visibility even

play08:59

though it's not supposed to

play09:01

but this will allow us to keep it off

play09:06

we will then add a main menu

play09:09

so we will just create a new control

play09:11

node and then we'll type in main menu

play09:15

then we will add a margin container

play09:18

we'll add a panel

play09:21

then underneath the margin container we

play09:25

will add a v box

play09:27

and then another V box

play09:32

and then we will add a label

play09:37

this will just be the title of our game

play09:40

so good o for RPG

play09:44

then we will add another V box

play09:48

and these will be our buttons

play09:52

then we will add a button and just

play09:53

duplicate them

play09:57

this will be our play button

play09:59

this one will be our settings button

play10:02

and this one will be our quit button

play10:06

then lastly we will add in uh by

play10:09

instantiating our pop-up panel

play10:13

and be sure that is automatically turned

play10:16

off of its visibility

play10:18

then we'll do control save

play10:21

or control s and then we will save this

play10:24

as main menu under our menus folder

play10:30

and we can also set the visibility of

play10:34

our margin container by clicking here

play10:37

and then we can click on The Middle

play10:42

we'll want to create a new script under

play10:43

our main menu

play10:46

and then while in doing so we can just

play10:48

remove this

play10:49

and then we can do onready VAR settings

play10:52

panel

play10:54

is equal to pop-up panel

play10:59

and then we will add some buttons

play11:03

so we can add in for our first button

play11:07

which I will rename to play this one's

play11:09

settings

play11:11

this one to quit

play11:13

we'll go under our play button click on

play11:15

node and then click on pressed

play11:19

and then we will type get tree

play11:23

dot now be sure to get this right

play11:26

because they changed it uh from Good L4

play11:30

which is to change the scene to file

play11:32

there's no longer change scene

play11:35

and then we just put our world here

play11:43

we can then go into our settings and

play11:46

then we can do the same thing

play11:48

for this one however we will do settings

play11:50

panels settings panel

play11:53

dot pop-up centered

play11:57

there are multiple other functions that

play12:00

I'll allow you to manipulate the panel

play12:04

lastly there's the quit

play12:08

and then we can just type get tree

play12:10

dot quit

play12:15

so one last thing we'll go under a

play12:17

project project settings

play12:19

and then under run we'll click on the

play12:22

folder there and then we'll go to menus

play12:24

and then click on main menu

play12:27

before we continue we need to go on to

play12:30

pop-up panel then under sound effects

play12:33

We'll add our sound effect sound

play12:36

which will be under our audio folder

play12:39

and then I can drag and drop here

play12:44

and then we can go under music

play12:47

drag and drop our music or our sun that

play12:49

we're using for it

play12:52

and as you can see we can hear it just

play12:54

fine

play12:57

we will then go on to our sound settings

play12:59

and then we will add in our bus names

play13:01

for sound effects we'll have sfx and

play13:05

then we'll have music for our music

play13:07

audio

play13:09

then under sound effect and music will

play13:12

change the buses here to their

play13:14

respective counterparts

play13:18

now depending on how loud your sounds

play13:20

are you may want to change them in this

play13:23

case I have a bit of a loud sound so I

play13:25

will just set it to less decibels

play13:29

and I'll do so for the sound of the Wind

play13:33

so now that we're actually in we can

play13:35

click on settings and then

play13:47

our toggles work

play13:51

then we can press play and then we can

play13:53

load into our world

play13:56

thank you all for watching hope this

play13:58

video has been very useful for you

play14:00

if it has please leave a like and a

play14:02

comment or a suggestion and I'll see you

play14:04

guys in the next video

Rate This
โ˜…
โ˜…
โ˜…
โ˜…
โ˜…

5.0 / 5 (0 votes)

Related Tags
Godot TutorialAudio SettingsVideo SettingsUI DesignGame DevelopmentSlider ControlsToggle ButtonsPop-up MenuGodot EngineSettings Panel