Godot Quick Reference

This page describes a subset of Godot's class library that may be useful for building simple 2D games. For more information, see the full library documentation.

Class hierarchy



Core built-in GDScript functions.

float clamp(float value, float min, float max)
Clamp a value to be with the range min .. max.
void print(…)
Print one or more values to the console.
float randf()
Return a random floating-point number in the range [0, 1].
float sign(float s)
Return -1, 0, or 1 in the cases where s is negative, zero, or positive.
String str(…)
Convert a value of any type to a string.

Area2D : CollisionObject2D

A 2D area that can detect when other collision objects overlap, enter, or exit it.


area_entered(Area2D area)
Occurs when another Area2D enters this one.

Camera2D : Node2D

A camera for 2D scenes. When the camera moves, the screen will scroll along with it.

CanvasItem : Node

A base class for 2-dimensional objects, such as 2D game objects (Node2D and its subclasses) or GUI controls (Control and its subclasses).

Vector2 get_global_mouse_position()
Return the current mouse coordinates.
Rect2 get_viewport_rect()
Return the boundaries of the viewport, i.e. the game window.

CollisionObject2D : Node2D

An object that holds one or more 2D collision shapes.

CollisionShape2D : Node2D

An editor object used to select a shape for collision detection, such as a RectangleShape2D.

ColorRect : Control

A control that displays a rectangle filled with a solid color.

Control : CanvasItem

A user interface control.


A singleton object that reports user input based on actions, which are defined in the Input Map tab in the project settings.

float get_action_strength(String action)
Return a value between 0 and 1 representing the intensity of the given action. For some input devices such as joysticks, this function may report continuous values. For a keyboard, this function will always return 0 (if a key is not pressed) or 1 (if it is).
bool is_action_pressed(String action)
Check if an action is pressed.

KinematicBody2D : PhysicsBody2D

A kinematic body, which has some physics support for velocity and collisions.

Label : Control

A label control displays plain text, either on a single line or wrapped inside a rectangle.

String text
The text to display.


A game object. A tree of nodes is called a scene.

String name
The node's name, which appears in the scene tree in the Godot editor.
void _physics_process(float delta)
Called during the physics processing step of the main loop. delta is the number of seconds that have elapsed since the last call to this method.
void _process(float delta)
Called on every frame. delta is the number of seconds that have elapsed since the last call to this method.
Node get_node(String path)
Retrieve a node by path, which may be either relative to this node (e.g. "paddle" or "ball/sprite") or absolute (e.g. "/game/left/sprite").
In GDScript, you can use the $ operator as an appreviation for calling this method; for example, $paddle is the same as get_node("paddle").
SceneTree get_tree()
Return the SceneTree that contains this Node.

Node2D : CanvasItem

A 2D game object.

Vector2 position
The node's position relative to its parent.

PhysicsBody2D : CollisionObject2D

An abstract base class for 2D objects affected by game physics.


A rectangle.

Vector2 position
The upper-left corner of the rectangle.
Vector2 size
The width and height of the rectangle.

RigidBody2D : PhysicsBody2D

A body with full simulated 2D physics.


An object that holds the hierarchy of nodes and runs the main game loop.

void quit(int exit_code)
Quit the application.

Sprite : Node2D

A node that displays a two-dimensional texture.

StaticBody2D : PhysicsBody2D

A body that is not intended to move, and is useful for implementation stationary objects such as walls.


A string. The syntax s[i] retrieves the i-th character of a string s. The '+' operator concatenates strings.

int length()
The length of the string in characters.
String to_lower()
Convert a string to lowercase.


A singleton object for working with time.

int get_ticks_msec()
Return the number of milliseconds that have elapsed since the engine was started.


A 2-dimensional vector. This class is also used to represent points in two dimensions.

The '+' and '-' operators perform vector addition and subtraction. The '*' and '/' operators will multiply or divide a vector by a scalar.

Vector2(float x, float y)
Construct a Vector2.
float x
The x-coordinate.
float y
The y-coordinate.
Vector2 normalized()
Return a vector scaled to unit length.
The constant vector (0, 1).
The constant vector (-1, 0).
The constant vector (1, 0).
The constant vector (0, -1).
The constant vector (0, 0).