Sites


Initiation à Godot

Nodes and scenes

Nodes and scenes

In Godot, we have several kind of structural element that will help organize the game. Nodes and Scenes are some of the most important, and a way to define how elements are mixed. They are available to user by GUI options which help any kind of contributor to work on its part without programming knowledge.

Nodes

Nodes are really common in many softwares and technologies. The most known of node system is the XML language that on which web structured language HTML is based.

The principle of node is simple, jus like box into box into box …:

  • You have a first element often called root.This element can have property, for example a position.
  • In this element you will add other ones. They will be considered as children of the first element, which becomes a parent. In most cases, children inherit from parent properties but can also have their own. In our case, default position will be the same as the parent but could also be customize. Defining if a property can be change is a question of design.
  • More on, those children element can have their own children and so on. At the end, this can result in a quite complex organization.

// poupee russes images

In Godot, the Scene panel will display the node tree of the current scene. To help designer in the game production, Godot team have created several node types that does some specific job. For example, you will have a node to add a sprite, but another node if you want the sprite to be animated. You will have nodes for 2D games and other for 3D games. The cool thing is that those node comes with properties than can be gui-managed or scriptable, and really speed up the production process. Godot Nodes can be viewed as predifined game objects that you use without having to program everything from scratch. Combining nodes is a way to create complex mechanics from simple base objects. At the end, Godot is coming with a quite huge quantity of Node types and it takes somes times they get used to all of them and learn how to mix them.

Nodes properties can be defined like this :

  • a node has editable properties related to its type
  • a node has a name that can be used as an identifier
  • a node is place in the node tree and can have parents or children
  • a node is extendable (scripted or via node tree)
  • a node is scriptable and can receive callback functions

An extract of available node base on «node» keyword only

The most difficult part in nodes will be to make decisions : how do I compose my node tree to get the result I want ? Those decisions should be first based on the game design and then come to Godot. There, a good knowledge of Godot can help. Some types won’t work together because they are not designed to, and even for compatible nodes, the way the tree will be setup can affect the result. In this case, knowledge base and experience will be the best friends. We learn game production by producing game, and we learn Godot and increase our efficiency with it by doing games with it.

Scenes Instances

As combining nodes is one the most important part of the game production process in Godot, why do we use scene ?

In fact, as powerful the node system is, you could make an indigestion. Puttings nodes in nodes in nodes in nodes can result in a real complex tree. The risk is to loose the control of the project because of the complexity of the tree. That is  where scenes come up. 

Scenes Instances will be our way to simplify our game tree. In Godot, a scene is not a place, or a stage where things happens. It is simply a combination of nodes that is saved on disk, and that we will reuse. In our design, we will use scenes to divide our game into more little part. In fact, as little as possible. The more little the scene content will be, the easier the. will be to manage and reuse.

// ajouter schémas ?

Scenes can be described like this :

  • a scene is a file with a .scn or .xml extension
  • a scene can be instanced (reused) in other scenes
  • a scene contains nodes that will be a part of the complete games

In some ways, we have divided the Node tree to a Scene list. This list will be much more easier to organize and, at the end, the game will result in a scene tree that will handle node tree. And in fact, launching a game is just launching a scene defined as is in the game settings.

An extra benefit of scene system is that it is a good base to work on to have better performance. As scenes can be reused, the experience at runtime will more fluent because their is less in memory. Of course, this is basic optimization approach but if it is not done at this step, it will be hard to improve in other parts. In fact, scenes are the primary resource we’ll use to set up the game and they worth the effort of their importance.

Il y a une erreur de communication avec le serveur Booktype. Nous ne savons pas actuellement où est le problème.

Vous devriez rafraîchir la page.