Tips for Godot 4.0 Developers Just Getting Started

December 18, 2023

This post is very much a work in progress with scattered notes about stuff that may be undercovered out there, and hopefully it helps someone along their journey.

2D Pixel
If you want those 2D Sprites pixel-perfect but can’t find the 2D Pixel preset – instead, go to Project Settings -> Rendering -> Textures -> Default Texture Filter -> Nearest.

Y-Sorting
If you are below the + sign, you’ll appear in front of the tile, if you’re above it, you’ll appear behind the tile. You can move it up and down in the Tileset tab under Painting (dropdown->YSort) and set a value. Negative values move the Y-Sort center up, and positive values move it down. Don’t forget to click on the tile area you want to set the spot for.

change_scene_to()
try change_scene_to_file("res://your_scene_name)

Not Declared in the CurrentĀ Scope:
rather than this syntax, add Callable
MusicOptionButton.connect("item_selected", self, "_on_MusicOptionButton_item_selected")

like so:
MusicOptionButton.connect("item_selected", Callable(self, "_on_MusicOptionButton_item_selected"))

Onready and Export now need an @ symbol at the front:
@onready var pause_menu = $PauseMenu

How do you loop an audio sample?

Answer by freeman:
First, when importing the sample, loop option has to be checked.
Then in SampleLibrary where the sound is imported, small pencil icon has to be clicked.

Now, the Inspector tab panel will show and let you set some of the properties of the imported sample.
Loop Format sets how to loop is going to be created:
None – no loop at all.
Forward – from start to the end and again from start to the end.
PingPong – from start to the end then reverse playing from end to the start.

Loop Begin indicates the start point of the loop.
Loop End, the point where loop will end.

After setting Loop Format for example to Forward, Loop Begin to 0 and Loop End to 1000000000, the sample will play from the very beginning to the very end, then when reaching the end will start to play again.

Other changes from GDScript 1 to GDScript 2:

  • instance is now instantiate
  • rand_ is now randf or randi (float or integer)

As of Godot 4.2 AnimationPlayer has had some consolidation and updates.

No Comments

Comments are closed.