Basic terms
-
Tabs
-
No
;
-
Comments are done with
#
-
Function is
func _name():
-
Variables are
var
,const
-
Basic logging
print()
-
if
andif not
(not parentheses):
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
-
not
,and
instead of ! and && -
each indentation = block of code
Common standard functions
print()
rotate_y()
(radians)deg_to_rad()
Working with settings
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity");
This gravity value is set in Settings -> General -> Physics -> 3D.
Other settings could be accessed in the similar manner.
When default settings are changed, project.godot
file is being updated with the corresponding values.
Here’s an example of changing the default gravity value in settings:
[physics]
3d/default_gravity=9.5
Getting keys
Keys = actions.
Handling example:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if Input.is_action_pressed("ui_left"):
rotate_y(deg_to_rad(-ROTATION_SPEED))
else:
if Input.is_action_pressed("ui_right"):
rotate_y(deg_to_rad(ROTATION_SPEED))
elif:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if Input.is_action_pressed("ui_left"):
rotate_y(deg_to_rad(-ROTATION_SPEED))
elif Input.is_action_pressed("ui_right"):
rotate_y(deg_to_rad(ROTATION_SPEED))