All There Is To Know About Godot's Scenes and Nodes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in a previous video we saw that nodes are the smallest building blocks of your good games you can think of them like legos put enough together and you'll have a character a car a racetrack an inventory or anything you can think of there are dozens of kinds that you can use to display an image play a sound represent a camera and much more we also saw that you can create a hierarchy of nodes and save them as a scene a template you can reproduce at will in this video we'll look more closely at nodes and scenes to help you get a clear picture of what they are because they are so central to good at projects and then you will create and run your first scene this lesson is part of a complete free course to get started with godot and there's more to come so be sure to subscribe that way you won't miss out okay so nodes have five attributes they have a name they have properties which you can edit in the inspector or access with a script nodes receive function calls from the engine to update every frame amongst other calls you can extend built-in node types with new properties and functions using script you can attach a node as a child of another the last feature is what brings us the scene tree we talked about two lessons ago i'd mentioned something about update so let me explain games work in a loop many times every second the game engine updates the virtual game world calculates how everything moved or changed then it paints it on the screen this happens typically 60 times per second although that can be more or less this is how you get the illusion of movement and life in a game there is a loop that updates many times per second and draws new images on your screen what almost every engine does is to give you a function in code that dictates how an entity should update between two frames in godot this function is available on every node and i'll stop there because we will see it in another video so we also saw that when you have multiple nodes together you can save them as a scene you can then create reproductions of these scenes in a game level for example in which case it looks a bit as if it was a node even though godu is just hiding the complexity to make our job easier but in a sense it makes scenes work as new and more elaborate building blocks than the individual nodes you can then use scenes to structure your game's code however you want nodes allow you to make scenes which will be the foundation of your good games and so the good editor is mostly a scene editor it provides you with many tools to edit 2d and 3d scenes with 2d including both 2d games and user interface a go-to project can contain as many scenes as you need this can be just one scene for simple games to hundreds or even thousands of them for large projects the engine only requires one that you will set as your application's main scene this is the scene that guru will first load when you run the game we went over the attributes of nodes let's now look at the ones of scenes scenes always have one root node like the character in the example used so far you can save them to your hard drive as files and load those files later you can create as many instances of a scene as you would like for example we can create two three four reproductions of this character scene you will now get to create your first scene and run it in a game window when learning a new programming language the first little exercise we do is typically displaying the text hello world and so this is what we'll do nothing fancy but in a few lessons you will be making a complete game so keep in mind while building towards that all right let's create our first project i invite you to open godot and we'll start from zero by creating a new project here i'll call it my first scene and click the create folder button so goto creates an empty directory for me this is a prerequisite to make a good project you can change the renderer to open gles2 because it runs on everyone's computers or almost while opengl es3 will run on more recent hardware let's say so click create and edit and we're going to create our first scene we just want to display some text get our feet wet create one label node and to do so we're gonna head to the scene dock in the top left and we have two options to create our label we can either click the plus icon which is always there in the top left of the dock or we can click the other node button as we don't have any nodes in the scene we have this option here these four options but we don't want any of these three 2d 3d or user interface we want to create an other kind of node so click that and look for label you can press enter to create it and we get to the 2d main view automatically because user interface is created in two dimensions so we see our label it's a little bounding box in the top left of our viewport with some anchors here in green you don't have to worry too much about them but with the label node selected we can edit its text in the inspector on the right and we want to set that to hello world and the text appears it's a bit small but it appears in the top left corner so now we're going to center the nodes in the window so you can click and drag on the node so you want to avoid clicking and dragging on the handles which will resize the bounding box click and drag on the text and just in case it doesn't work make sure that the leftmost tool is selected in the toolbar it's called the select mode it's the little arrow now we have our scene done that's all we wanted to do i know it's not much but it's a start and we can play the scene we can execute the scene and all the code in there that is on the label in our case by going in the top right and you have a few buttons the first play button plays the entire project it plays your game from the start so it could be a main menu something like that then you have a scene icon with a little play button inside and this one plays only the currently edited scene so this one and you can click it or you can press the shortcut f6 and this dialog opens and invites you to save the scene before running it so you can leave the default name and press enter and our hello world will display in a new window this is a preview of what your players will get when you distribute your game and you can test that directly from the godot editor okay we'll do one more thing here is set our project's main scene as our label scene and to do this we can click the play button or press f5 and gudo will ask you to choose your game's main scene so i'm going to click the select button and select our label.tscn scene file same thing happens every time you would press f5 when editing your project this scene that you set will run there's a shortcut you can use to close this window it's f8 and so finally i just want to mention that this main scene that we set you can change it anytime from the project menu project settings and run tab you have the main scene path here and you can click the folder icon to change it just in case you want to change that in your project later in the next video we'll talk about scenes and instancing we will see what it is what it does for you and you'll get to play with bouncing balls so be sure to subscribe so you don't miss any and if you want more good content right now i wrote a complimentary series to this little course here it's on our website it will teach you more about godot and game development in general you can get it right now it's completely free and the link to access it will be on the screen and in the description below with that i'll see you in the next one bye
Info
Channel: GDQuest
Views: 97,003
Rating: undefined out of 5
Keywords: godot scenes, godot nodes, godot beginner tutorial, getting started with godot
Id: y0QAvyv9Wbw
Channel Id: undefined
Length: 8min 13sec (493 seconds)
Published: Thu Mar 11 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.