Moving a simple game from the Godot 2 engine to Godot 3

Godot logo (CC-BY 3.0)
Godot is a free game creation engine, distinguished by a fully functional editor on all desktop operating systems. Version 2 was a very comfortable environment for creating 2D games.

In the case of 3D, it was not so colorful anymore, the engine was very limited and not usable at all. Version 3 has introduced many improvements including a virtually new rendering engine. Now 3D looks really beautiful.

Although the general principles of working in Godot are the same, a huge number of changes under the hood requires adaptation of old scripts to work in the new version.

Project file engine.cfg -> project.godot

At the beginning I just wanted to import an old project.Unfortunately, it was not possible.New Godot asked me to indicate the file project.godot, and in version 2 the settings file was called engine.cfg.A quick comparison of the content indicated a lot of similarities in the format, but in the end I decided to create a project anew in Godot 3. In this way I wanted to avoid possible conversion errors.

The position of nodes

In G2, to get or set an item you had to use the get_pos () / set_pos () function, this usually involved creating additional variables such as pos. G3 solves this problem and now the position is set using the position property.


pos = get_pos()
pos.x += 10


position.x +=10

Physics support _fixed_process () -> _physics_process ()

In addition to renaming, you no longer need to call set_fixed_process () if the _physics_process method exists its active. Similarly with other callback functions such as _input, _process.

KinematicBody2D move () -> move_and_slide ()

The move() function is no longer available, and move_and_slide() replaced it. In addition, we have the move_and_collide() function, which stops the body movement in case of collision.

Counting frames per second OS -> Engine

The functions related to the engine, not the operating system have been transferred to a separate class.





Types of events

The events no longer have a type field, if we want to check their type, we use the is operator, eg:


if event.type == InputEvent.SCREEN_TOUCH:


if event is InputEventScreenTouch:

Simplified node getting

In G2, as we wanted to get a child node, we had to use the get_node() function. In Godot 3, we can just use $. Of course, the get_node() function is still available.