Hey guys.
Once again we brought you things that are very helpful, but hard to find and
too small to make a video about them on their own. The best thing about this series is that this
video is objectively better than the last one, because we have 13 things this time.
Number 1: Evaluate expressions shortcut. You won't ever need a calculator app
again, at least when scripting in Godot. You may know that in property
fields, you can input expressions and press enter to evaluate them.
But you also do this in the scripting window by marking the code and pressing Ctrl+Shift+E.
This way, you can multiply large numbers or decimal numbers, do vector
calculations and manipulate strings. It can do quite complicated maths that
you really would not want to do yourself. Thank you, BareTuna, for
submitting this very unknown trick! Number 2: The love child of mix
blending and additive blending. You can use different blending modes
based on different canvas item materials. But especially for visual effects
you sometimes are not sure if you want to use mix with a transparency or add.
Add is great because it does not obscure the image below it and it is generally beautiful.
But too many additive layers result in pure white soon, they just do not
work to well on dark background. You can get the best of both worlds by using
a mix with a transparent sprite, and putting the modulate higher than 1. This practically
gives you something between blend and add, which look as good as add on dark
backgrounds, but still nice on lighter ones. Number 3: Smartshape2D.
Smartshape 2D by remorse107 is an impressive addon that gives you 2D
polygones that are textured really nicely. You can get it on GitHub or
find it in the asset library. It also supports bezier curve shapes and lets
you define specific border and corner textures. There is a great tutorial by
picster on how to use the addon It is really cool for level creation especially
in case you don't entirely rely on tilemaps. Number 4: A simple way to scroll Textures
There is a very easy way to make scrolling textures that Nate told us.
You can use this sneaky little property of a sprite, which is the sprite region.
It is not only good for sprite sheets and such, but you can enable wrapping on the texture and
make elements like these with low performance cost and without a shader.
Number 5: Print loaded scenes. Ever wondered which scenes are loaded when?
We just did when we tried to reduce our games startup time.
Turns out, there simply is an option for that. Just go to “Project settings -> debug ->
verbose std out” and there you have it. You get these nice little prints in the
console whenever anything is loaded. And it also prints memory leaks.
Number 6: Ways to draw simple shapes. Many of us use the Godot icon as a placeholder
for basically anything when prototyping. However, sometimes it can be helpful to have something
other than the little robot face to create some contrast. Such as Color rects! These
control nodes are flat rectangles and you can resize them however you need. For other
shapes, you can use a variety of draw functions, for example for circles, lines and polygons. Just
add a Node2D into your scene, give it a script and add a _draw() callback function with
some draw calls.This is really helpful to draw shapes on the fly when debugging.
Thanks Stefano Bertolotti for the tip. Number 7: Draw offset property
A draw offset allows to change the center of a graphic.
Sprites have the offset property, that also changes where they are drawn, while
control nodes have the privit offset which does not change their location.
This comes in handy when scaling or rotating the sprite.
They can even lie outside of the graphic itself. Number 8: Attach metadata to objects.
Meta data is a very powerful tool when dealing with dynamic data and for debugging.
You can just attach any key value pair to any node or type that inherits from
object. Just call set_meta. Later, you can check if the object has specific metadata
with has_meta and get the value through get_meta. For example, you can annotate when an
object was created or where. You can use this whenever you don't want to add variables.
This trick was posted by Winston Yallow, who uses this for marking meshes, really cool, thanks!
Number 9: size of children in containers. Containers are very helpful
tools when creating UI. They resize and arrange their
children nodes automatically. When you instance these child nodes
programmatically and need to know the resulting size or position, you cannot
access it in the same frame as the node was added to the container. Instead, you have
to wait a frame for the container to update. This can be achieved with the line
yield(get_tree(), "idle_frame"). Number 10: Ruler in editor for measuring.
Did you ever notice the rulers at the left and top of the scene editor? They display the pixel
height and width. But that far at the side, it's hard to use them to measure distances. By clicking
on the ruler and dragging it to the right or down, respectively, you can create reference lines
with defined x or y offsets. You can also mark positions by dragging from the top left corner.
To get rid of the line, just drag it back to the ruler by clicking on the line's
end on the other ruler. It can really help when designing UI, for instance. This
trick was shared by MumuNiMochii - thanks! Number 11: How to run server and
client Godot projects at the same time When you try to run two Godot projects at the
same time, say if you're making a multiplayer game and have a client project and a server project,
the second one will refuse to start with "Error Listening on port 6007."
To circumvent this, change the port in one of the projects by going to Editor
-> editor settings -> Network -> debug and set the Remote Port to another port. Tom
Tomkowski told us this trick, thanks! If your client and server are in the same project
and you want to run two instances of it, start one as usual and the other one through the project
manager which has a Run button! Thank you, Geshtu. Number 12: Remap navigation buttons for 3d
In the 3d editor, you normally orbit with the middle mouse button and when pressing shift
and the middle mouse button, you can pan. You can change these settings under Editor
-> Editor Settings and search for navigation. There you can set Orbit, Pan and Zoom buttons.
The option “Emulate 3 button mouse” allows you to use the function of the middle mouse
button without pressing any button, just by moving your mouse and pressing the modifier button.
This one was submitted by Saiponath Games, thank you.
Number 13: Choose the sizes for generated textures.
Be aware of the default sizes of curves, noise textures and gradient textures.
You can set them. Often times they are set to a very generous
amount, that you will likely not need. For example, let take a look
at this particle system. We vary the color of its lifetime,
based on this gradient textures. Works quite well, but do we really need
a 2048 pixel texture for the color of a particle that only lives like 120 frames?
Especially with simple gradients you can reduce this amount quite a lot, because
there is still linear interpolation going on. This one looks good down to about 5
pixels, but we can be generous and give 20. This is still a lot less.
We hope this was helpful for you! If you want to learn more things about Godot, subscribe
to this channel. If you liked that video, show us by pressing that like button. Many if
that tricks come from our awesome community, so if you have an useful Godot trick to share,
put it in the comments, we would love to read it. Oh, and by the way, we are working on a colorful
roguelike that is called “Furcifers Fungeon”. If you want to see us progress, check out our devlog.
Have a nice day!
Thanks, I found the evaluating shortcut (Ctrl+Shift+E) and the particle texture's size very handy. Didn't know about them. You're increasing the numbers each time, so looking for your "14 tricks" next time! ;)
this looks cool and all, but the thumbnail with the pointless, overcomplicated code bothers me. It equals 1337 btw if anyone wants to know
I really wish I had known about node metadata a lot sooner. I've made entire classes before just for adding new properties so this should be extremely helpful, thanks!