6 Tips to Better Organize your Godot Projects

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you have trouble structuring your projects in Guddu or do you wonder how you should make your scenes how you should handle your project structure your folders etc how you should name things I'm going to give you tips in this video based on my experience but also feedback from much more experienced developers things I wish I knew when I started first we're going to look at the scene structure a scene in Gazoo represents codes like a class in an object-oriented programming language even if you are using an editor and you have nodes that are here that are not exactly like programming you can add them through an interface these nodes represent member variable that you would write by hands if you were using a pure language like C++ Python JavaScript etc these nodes and the hierarchy is a form of programming that we call declarative code declarative codes is code that represents what you want to achieve but that doesn't give away the details of how the computer is going to achieve that when you write a script and Gd script line by line you give the computer very specific instructions about what it has to do step by step but when you look at the scene tree these nodes they can do things for you take the timer for example you can set it to automatically start to play only one time or to loop and to tick every wait time seconds in this case every one second it doesn't need to have a script attached you don't need to write specific code about it but more importantly you watching this scene you can look at the timer you know that it's a timer it's going to act like a timer but you don't know how exactly it's going to calculate time intervals and all that stuff and that's very powerful because it makes your code and your project self-documenting you can think about your future self on the one hand you coming back much later to your project or to some monster or parts of the game you have to change and you don't remember how it works at all you can open the scene look at the scene tree and if you named and had a good hierarchy you will have a very good sense of what's happening exactly so the porcupine has animation play a node so it's animated collision polygon it can interact with the world it has some sprites here and a buddy pivot nodes I use this quite a lot I actually should name this pivot in that case it's a pivot points that you can use to move rotate the monster and everything that goes along with it state visualizer it's going to show state the monster is currently in it has an obstacle detector raycast node it's a bit hard to see on the screen but this one allows it to detect obstacles as the name suggests debug dro fixed and moving corresponds to the elements that are currently drawn on screen that is the detect range for the monster where it can start to see the player next there is the bolo range this is the limit distance to the player beyond which the monster will go back to its spawn position and this spawns position and area is the blue circle in the center and this is fixed drawing while the other two move along with the monster last but not least it has a direction visualizer here which is this arrow you can see and this gives you a hint about which direction monsters and entities are moving in the world while I don't have sprites yet with all the moving directions it's very handy when you are prototyping the game but just looking at the scene tree I have a lot of information about what the monster can and cannot do and switching to another project using the states pattern a programming pattern that allows you to break down behavior into self-contained scripts and objects I have a player here that has a few of the same properties as the monster so it has some sprites and animation player but more importantly it has nodes for its states that represent its behavior so you can use the scene tree to describe what this character or this entity can do this one can be idle moving or jumping later on in the project I could add other states like attack or something name should create a new script and when I'm much later into the project I just have to open this scene look at the States node and I know what the character can or cannot do as far as the names are concerned I recommend keeping things as simple as possible first do not use red Indian names I had the pivot called body pivot then there was the body under it it's just a pivot so I'm going to name it pivot note that finding good names when you are programming is a skill that you have to learn it's pretty hard I try to not use more than two words for anything be it a node in this case but also for my project structure moving to the project structure I use folders to separate different unrelated areas of my code for example the characters and the monsters in this game have a completely different code base so they are in two different folders if I go down the monsters folder I have two monsters the mosquito and the porcupine this project is small it's for educational purposes so you won't find a very deep hierarchy of folders but the ideas use the folders to categorize your codes your sins and to group related elements together and I really recommend to keep the content of the folders quite specific when you go deep down the tree so for example for my mosquito my flying enemy I have two scenes the related scripts and sprites and if I had more sprites there would be grouped in a subfolder called sprites maybe and nothing more I could have all the content of a mosquito folder and the porcupine grouped together here the folder structure is representative of your projects architecture the next step is about moving things around and renaming them in your project make sure that you do everything from within the file system Ducker so Godot has all the functionality you need to move folders and files and this is very important because look at my level scene right here I'm on the game's level and I have a player a porcupine that I instantiate it two times from the system dhaka when you add these scenes into another scene it gets written into your TS CN files which are text files for example in the level I'm going to have three references to the porcupine itself if you want to move something and you just drag and drop it on a different folder maybe good it will update the definitey paths but if you use the move to function you can be sure that it will do so and also displays your folders as a tree where you can navigate and find the exact folder where you want to move things the same thing now for renaming you can use the built-in rename functions to do that and it's going to fix all the dependencies in the scenes in which you've in Senshi ated the element you just renamed now I'm going to enter the player scene to show you something very interesting and very important the player or the character basing in that case has an animation player with a few animations you have the nodes on the one hand that's add behavior to your game and on the other hand you have resources that store data so when you have a tile set that you plug into a tar map or a sprite that you plug into a sprite node the sprite the tile set are resources there are chunks of data they don't do anything everything like the animations in your animation player are resources the thing right now is it's not a file in your file system but I want to show you two things first that it's available as tex let me head to the character folder i'm going to open the character scene in my file manager and i'm going to open it in my text editor here if I look here on the line seven you can find a sub resource of the type animation and you can find all the data for your animation so you have the name of each animation starting with set up you will find the various tracks inside of it and the keys that are on each of the track because this is text you can copy and paste these chunks of text data and reuse them across scenes then what's more interesting even is that instead of using the scenes built in resource you can create a new resource in the inspector you can choose a resource of the type animation and when you do so can then use the Save button to save it as a text resource stairs stands for text resource and you can place it inside your characters folder for example so this means that you can reuse the resource afterwards across scenes so most of the time go-to will create resources for you and store them inside of the scene and to reuse the resource you can do what I did here in this project the player is an inherited scene you can see that to the grayed out nodes in that if this means that it shares all the original nodes from the character scene in this case bouncing back to naming tips I told you you don't have to repeat yourself with the names and what I mean by that is for example look Here I am in the characters folder and in there I have a sprite that I could call character dot PNG but instead I'm calling it body dot PNG because from the folder structure I know that this is the character's body because it's in the characters folder it's a bit different for all scripts and scenes for the scene I used the same name as the root note of the scene because it's going to be shown in the interface and it's the same thing for the script it's important to have a descriptive name in case you'd like to work full screen like that you can use the f11 key to fold the tabs or the ducts on the site so that's it for the introduction to project structure we'll get to talk about this a little more in the future especially looking at how to write your scripts how to organize them I had the opportunity to learn a lot from more experience that in that regards that said thank you came before watching be creative have fun hand see you in the next one bye bye
Info
Channel: GDQuest
Views: 85,151
Rating: undefined out of 5
Keywords: godot project structure, godot best practices, godot file, godot scene tutorial, godot node tutorial, godot game engine, game development, game engine, godot engine, godot 3, godot, open source, game creation tutorial, game development for beginners, godot 3 tutorial, game development tutorial, godot 3.0, godot 3.1, godot filesystem, software structure, game structure
Id: fpUchzKtDbQ
Channel Id: undefined
Length: 11min 39sec (699 seconds)
Published: Wed Apr 18 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.