10 Tricks We Wish We Knew Earlier | Godot Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Godot is a great engine. But it has its fair share of unexpected behaviors and hard to find features. Here are 10 of them we wish we know when we started. Number 1: How resources work Resources are great if you want to use the same data in different parts of your game. However, when you change a resource it will change everywhere it is used, as long as it is not made unique. When you want to make a nested resource unique, you have to make its subresources unique from top level to the bottom level. Otherwise, the dependency will end up like this. When you change the resource at runtime, it must be made local to scene with this button, or duplicated in code like this. Number 2: How yield works Yield is helpful, but a bit strange. When the code execution finds a yield, it immediately returns. It makes a mental note to resume the function, whenever the specified signal happens. This allows complex sequencing within a single method, without the need for a separate callback method. You can even create a temporary timer and wait for its timeout in a single line. Be aware that a method can yield multiple times if it is called multiple times. And when the signal comes, all started executions of the method are resumed, each one keeping its local state. Number 3: Particle shaders exist In godot you can add features to the particle systems with particle shaders. They are really useful, we made a bunch of tutorials about them! You can make particles fly in curves, explode sprites in pixels and much more! Number 4: Class name Giving classes a name is really helpful. You just write class_name and then the name at the top of your script. You now can extend the class in a much cleaner way. Also, you can instanciate it without loading it every single time. Be aware this feature exists before doing it with a lot of preloads like we once did. Number 5: How collision shapes behave Dynamically resizing collision shapes is tricky at the moment. This will change with Godot 4, but for now it can be buggy when you scale the shape or a node above it. You should not simply change the properties of the shape either, because this will effect other instances of the same shape resource. The cleanest way right now is to instanciate a new shape in code. On the bright side, you can put as many collision shapes below a PhysicsBody or Area as you want. This often is easier and more performant compared to a single very complex shape. Number 6: Import options There is an import options tab, and it is important. When importing textures, you can turn of the filter for a pixel perfect look. You can enable mipmaps for downscaling or if you use textureLod in a shader. Also, there is an option for repeating textures and many more. Number 7: Autoload You can add nodes or scenes that should always exist to the autoload tab. They are loaded and added once to the scene tree before your game starts. Also, you can use it for global constants, scene transitions and more. They have a global name, so you can access them from every script. Number 8: Signals Godot’s signals allow you to make nodes that can add functionality to another node. Lets say you want to implement a health bar, simply emit a signal when the health changes. A health bar can listen to it, if it wants, but is okay if it does not. Signals are a great practice to use because they decrease coupling. A less commonly known feature are the binds. You can add an array of arbitrary information that gets passed to the registered function as soon as the signal triggers it. This allows reconstructing which connection lead to the callback. Number 9: animate everything The animation player and tween node can animate almost anything you can think of and have tons of great smoothing options. Animation players are great for fine grained control over complex animations, Tweens are lightweight and have to be used in code. They are definitely a big strength of the engine, we made a video about that with more details. Number 10: GdScript has optional typing and optional parameters. GdScript is quite a capable language if you know its features. One of the cooler ones is the optional typing you can do when declaring a variable or parameter. We would advice you to use them pretty much everywhere. They also work with return values of functions. Remember the class names from number 4? You can use them too, for optional typing. With that you can make sure a function gets passed an enemy, not just any object. And the editor will even auto-complete the enemy’s properties and functions. Gdscript also allows optional parameters, simply write the default value behind with an “=”. When no parameter is passed, this value is taken. This often is is much better than making different variations of the same call. These were 10 things we wish we would have known when we started out. What are things you would have liked to find out earlier? If you enjoy our content you can like, subscribe and comment! This makes us and the youtube algorithm very happy.
Info
Channel: PlayWithFurcifer
Views: 16,426
Rating: undefined out of 5
Keywords: Godot Engine, Godot, Game Engine, tutorial, Furcifer, Godot tutorial, Godot tutorial 2d, signals, yield, beginner tutorial, gdscript
Id: UqnwfxaMxBU
Channel Id: undefined
Length: 4min 53sec (293 seconds)
Published: Sun Apr 11 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.