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.
Project file engine.cfg -> project.godot
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.
G2:
pos = get_pos() pos.x += 10 set_pos(pos)
G3:
[python]
position.x +=10
[/python]
Physics support _fixed_process () -> _physics_process ()
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 ()
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
G2:
[python]
OS.get_frames_per_second()
[/python]
G3:
[python]
Engine.get_frames_per_second()
[/python]
Types of events
The events no longer have a type field, if we want to check their type, we use the is operator, eg:
G2:
[python]
if event.type == InputEvent.SCREEN_TOUCH:
[/python]
G3:
[python]
if event is InputEventScreenTouch:
[/python]
Simplified node getting
get_node()
function. In Godot 3, we can just use $
. Of course, the get_node()
function is still available.G2:
[python]
get_node(“node_name”)
[/python]
G3:
[python]
$node_name
[/python]