10 TRICKS YOU SHOULD KNOW (3) | Godot Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

I've never used set_as_toplevel(true) so far but it seems incredibly useful! Thanks for making these, I love this video format!

👍︎︎ 3 👤︎︎ u/golddotasksquestions 📅︎︎ Nov 16 2021 🗫︎ replies
Captions
We read the documentation, so you don't  have to. And this is what we learned.   Number 1: An easy trail You can make a trail in   a very easy way. Just use a line2D and  add a point to it every physics frame.   If you want your trail to be limited,  remove points when a certain number   of points is reached or it got too long. With a scale curve, this looks really cool.   Related to this: If you want to have a node  with a transform independent of their parent,   use set_as_toplevel. It then acts as if it   was a direct child of the scene tree root, and  therefore its position is its global position.   That way we can add the trail  as a child of a node!   Number 2: Helps to have a map! Organizing your project can be a hassle.   But L4Vo5 showed us a great solution. With this neat plugin called Project Map,   you can organize your assets in a map and group  your nodes. This can drastically reduce the   time you waste searching that one script. Just drag files from the file system panel   onto the map. To open the file,  you can click on the node name.   You can simply download this plugin from  GitHub or install it via the Asset Library.   Enable it in your project and you get this  tab on the top to open the project map.   Number 3: How can you even interpolate methods?! Tweens can actually interpolate methods, not just   properties. Simply use “interpolate_method”  with the node, the method name,   starting value, target value and duration.  The method will be called every frame with   the interpolated values. You can do very complex  stuff with that, like adding points to a line by   interpolating from the start to end position. It’s also super helpful whenever you want to   react to a property change. Note that you can only   interpolate a single parameter. Number 4: Inconstant Constants   In Gdscript you can declare variables  as “const”. This has a large advantage:   They do not need to be stored multiple  times for multiple instances of the class.   The most common usage of const is for a preload  because preloads are expensive and do not change.   The name “const” for “constant” implies that these  variables can not change. And this is true for   primitive types like an int. But for objects  “not changing” just refers to their identity,   not their state. So you can declare a const  String, Color or Array and still...change it.   It will be shared between all nodes. I  still would not advise doing that.   Number 5: Preload database If you ever find yourself preloading the   same scene in multiple scripts, it gets tedious  to update all of them when the path changes.   An easy fix is brought by skaruts:  Just put all of them in a data-class   where you reference them from. You can make it a node so you can   put it into your project’s autoloads and  access it from everywhere in your code.   Number 6: Fake 3d and diagonal squishing If you have a 2D node such as a sprite, you   can scale it in x and y-direction. But you can not  squish it sideways for shearing. If you want this,   you can use a vertex shader, we explained that  here. But you can also put another Node2D above,   and scale that one in the y-direction. You can  see, the sprite is now squished diagonally.   If you rotate the child node you have this kind  of pseudo-3d effect that looks pretty cool.   Number 7: Check your performance Most code is not performance-critical at all   and you should not bother optimizing it. But some  code is. To find out what code that is for your   project, you can use the profiler. Just go to debugger -> Profiler on   the bottom when you play. You can  see which functions take how long.   You can add and remove specific functions to the  plot, to see which ones contribute to a spike.   In this particular example, you can see that  instantiating becomes more and more expensive   as the scene tree is filled with sprites, while  the loop’s cost is identical in every frame.   Number 8: Engine shortcuts When working with Godot, you   tend to switch very often from the 2D/3D editor to  the script editor. And every second saved there,   is a bit of extra productivity. You can switch  faster than clicking using keyboard shortcuts.   The standard shortcut is Control + F1/ F2 / F3  depending on the tab. But you can change it,   like marbles did. For example to Alt+ Q/W and E.  Just go to Editor -> Editor Settings -> Shortcuts   and search for ‘open’. Number 9: Iterate everything   If you have a custom class that you  want to iterate, you can do this.   But you have to implement  the necessary functions.   These are _iter_init(),  _iter_next() and _iter_get().   This is most interesting if you  implement some kind of container   like a 2d array or maybe a dialog script. Usually, you keep an index to the current   element within the class. In _iter_init, you reset   that index to the first element. In _iter_next, you advance the index   to the next element and check if you reached  the end of your data structure. You need to   return the result of that check. In _iter_get, you just return   the value at the current index. Now, you can just create an instance of the   iteratable class and iterate it with a for loop. By the way: We discover this stuff by working on   our own game Furcifer’s Fungeon. A roguelike where  we draw everything that hurts you on the ground,   so we can throw randomized death at you.  Go to the description, click the link and   wishlist that thing. Give this video a like,  subscribe, share it with your grandma while you   are at it, and sell us your soul! Number 10: Animation player tricks   The animation player has a lot of cool features  hidden inside, as Dark Peace pointed out.   You can select keyframes, go to Edit -> Duplicate  selection and duplicate the selected part of an   animation. As a shortcut, use Ctrl+D. And down there, you have two helpful   buttons I always ignored. This little funnel there hides   all tracks except the ones referring to the  node you currently select in the scene tree.   Really nice if you have many tracks. And the list icon right next to it   removes the grouping which makes the list much  shorter if you use many different nodes.   So we hope some of these were  helpful. Let us know your tricks!   If you want to watch more of  this: Here are 10 more tricks!   And here are games made with Godot!
Info
Channel: PlayWithFurcifer
Views: 5,974
Rating: undefined out of 5
Keywords: gdscript, godot tween, godot project map, furcifer
Id: v1iFfCq3_Ao
Channel Id: undefined
Length: 5min 58sec (358 seconds)
Published: Sun Nov 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.