10 Tricks We Wish We Knew Earlier (2) | Godot Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
We bring you the finest Godot tricks from all over the multiverse. Some are simple, some are complicated, but all of them took us a while to figure out, and they will help you make your game! [pizza cam!] Number 1: Manipulate time. I love slow-motion effects in games, and they are actually pretty easy to do. You can use Engine.TimeScale to switch it on the fly. It’s really cool, pretty much everything is affected, except sound. Wait a moment. BB from our discord is here to save us! You can access the AudioStreamPlayer and change the pitch_scale in order to address that. And in case you just wanted to slow down the time your shaders see, you can do that with VisualServer.set_shader_time_scale, this is helpful to stop shader effects when pausing the game. Number 2: Animate Particles. There seems to be some confusion about how or even if you can animate particles. Yes you can, it is not hard to do, but a bit hard to find. We start with a simple particle system. We can use a sprite sheet or individual frames in an animated texture. For the sprite sheet, set the sprite sheet you have as the texture. Give the node a CanvasItemMaterial. Check “Particles Animation” and configure the number of rows (h frames) and columns (v frames) of your sheet. When you have a looping animation, check that too. The last thing you have to do is to go to the process material and increase the animation speed. When using individual frames, set the texture to an AnimatedTexture. Set the number of frames, the FPS and drag all the frames in here. That’s it! An advantage of sprite sheets is that you can have particles in different animation states. We found no simple way to do this with an animated texture. Number 3: Navigate 3D Scenes. You can navigate through the 3D viewport by zooming with the mouse wheel, rotating with the right mouse button and panning with shift+middle mouse button. But it is pain and I can’t do it. I wondered what I do wrong, and Cute Snake gave us the answer: You can use WASD to move - but only when you press the right mouse button. Or you toggle it with shift+f. You can adjust the speed in the Editor Settings -> Editors -> 3d -> freelook base speed, and fly around your scene as you deserve. You’ll be even faster with Zoom Link. If you found these tricks helpful so far, push that like button, so more people can see them! Number 4: Navigate Scripts. At some point in your project, you might have a LOT of scripts. You can push these arrows to switch to the scripts you recently opened. You can also use the alt + left arrow or alt + right arrow keys. If you want to navigate within a complex script, bookmarks can be helpful. Just go to the “bookmarks tab” or set one with Ctr + alt + b. You can use Ctr+B to iterate them and Ctr + shift + B to iterate them backward. Number 5: Shade Lines. The Line2D node is pretty awesome in general. You can give it a texture and a gradient, and make a really nice effect with that. But you can make even nicer effects with shaders, like obnoxiously big lasers. If you simply add a shader, the whole line just has the same color for some reason. But you can add a texture, so the shader is not insanely confused anymore. If you change the texture mode to “stretch”, you can simply use a single pixel. The UV.x simply goes along the direction of the line. And then you have this to obliterate your foes with. Have fun… obliterating. Number 6: Actually select the node you want to select. When you have a bunch of nodes stacked up, there are easy ways to get the right one. The first option is to lock nodes you don't want to touch. Just select the node and click on the padlock icon on the top. You can still move the node through its position property. But you cannot click it anymore. When you close the engine, the padlocks are gone. You can also use alt+right click to get a list of all hovered nodes and choose the right one. After you have selected the node, keep pressing alt so you will not switch your selection. Sounds super basic, but I did not figure that out until recently, and maybe I am not the only one. Maybe I am. Number 7: Find out if a node is deleted - the right way If a node is deleted, references to it do not automatically become null. So you cannot null-check an instance and safely access it. A version ago, this was different in debug builds, which led to crashes in release builds. It does still look weird when such a null-check crashes, as the debugger clearly says the instance is null, but it passed the check. So what can you do? You can set the reference to null yourself, but this gets hard when multiple references exist. A simple way is to use is_instance_valid() instead. This function will immediately return false as soon as the instance is freed. Number 8: Orphan nodes and how to find them. Orphans are nodes without a parent. And this is just so sad. Nodes get orphaned when they are removed from the scene tree, or instantiated and never added in the first place. The problem is, that they will not be deleted with their parent - because they don't have a parent, so if there is no reference left to them they just exist. Out there. In the void. Alone. So orphans might be fine if you do it on purpose, and only ever a problem when they accumulate. But there also is not really a reason to have them. You can prevent creating orphans by adding the nodes you instantiate into the scene tree. If you have custom nodes that you don't want to add to the scene tree, maybe think about making them a reference. You can check the number of orphans over the runtime when you go to Debugger -> Monitors and look for orphan nodes. Finally, you can get a list of orphans with the “print_stray_nodes()” call. Number 9: Signal Order. This one is really niche, but resulted in a bug that took us quite a while to figure out. You can connect multiple methods to the same signal. I always thought they would get called in the order they were connected, but they are not. There are no guarantees, sometimes they do, sometimes they don’t. The tricks we bring you often come from you guys, so if you have something you want to share with the community, let us know in the comments! All the tricks that are not from you, we find when making our game, Furcifer’s Fungeon. It is a fast-paced, bouncy, wizard Roughelike, with many spells and characters. We overhauled quite a lot in order to get it ready for the demo, click the link to our Steam page in the description and go wishlist that thing! Number 10: Pass data from particle shader to spatial shader You can access data from particle systems in the vertex shader. This is pretty useful to make really fancy effects. Use the vec4 INSTANCE_CUSTOM. It has the following values by default: Orientation angle, relative lifetime, maximum lifetime and animation frame. If you are writing your own particle shader, you can store everything you want in the CUSTOM variable. If you want to pass these values from the vertex shader into the fragment shader, you can write them into the COLOR variable. By the way: For spatial shaders, you can access INSTANCE_ID to get the particle id, unfortunately, canvas_item shaders do not have this. This trick was submitted by … uh… Krzysztof Swierzy! If you want more things, click here! And here we present some great games made with Godot, go watch that stuff!
Info
Channel: PlayWithFurcifer
Views: 4,106
Rating: 4.9829788 out of 5
Keywords: godot, gdscript, godot engine, godot 3d, godot 2d, furcifer
Id: QMSVLhmLJFg
Channel Id: undefined
Length: 7min 38sec (458 seconds)
Published: Sun Oct 10 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.