Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

@GDScript

Built-in GDScript constants, functions, and annotations.

Description

A list of GDScript-specific utility functions and annotations accessible from any script.

For the list of the global functions and constants see @GlobalScope.

Tutorials

Methods

Color

Color8(r8: int, g8: int, b8: int, a8: int = 255)

void

assert(condition: bool, message: String = "")

String

char(char: int)

Variant

convert(what: Variant, type: int)

Object

dict_to_inst(dictionary: Dictionary)

Array

get_stack()

Dictionary

inst_to_dict(instance: Object)

bool

is_instance_of(value: Variant, type: Variant)

int

len(var: Variant)

Resource

load(path: String)

Resource

preload(path: String)

void

print_debug(...) vararg

void

print_stack()

Array

range(...) vararg

bool

type_exists(type: StringName)


Constants

PI = 3.14159265358979

Constant that represents how many times the diameter of a circle fits around its perimeter. This is equivalent to TAU / 2, or 180 degrees in rotations.

TAU = 6.28318530717959

The circle constant, the circumference of the unit circle in radians. This is equivalent to PI * 2, or 360 degrees in rotations.

INF = inf

Positive floating-point infinity. This is the result of floating-point division when the divisor is 0.0. For negative infinity, use -INF. Dividing by -0.0 will result in negative infinity if the numerator is positive, so dividing by 0.0 is not the same as dividing by -0.0 (despite 0.0 == -0.0 returning true).

Warning: Numeric infinity is only a concept with floating-point numbers, and has no equivalent for integers. Dividing an integer number by 0 will not result in INF and will result in a run-time error instead.

NAN = nan

"Not a Number", an invalid floating-point value. NAN has special properties, including that != always returns true, while other comparison operators always return false. This is true even when comparing with itself (NAN == NAN returns false and NAN != NAN returns true). It is returned by some invalid operations, such as dividing floating-point 0.0 by 0.0.

Warning: "Not a Number" is only a concept with floating-point numbers, and has no equivalent for integers. Dividing an integer 0 by 0 will not result in NAN and will result in a run-time error instead.


Annotations

@export()

Mark the following property as exported (editable in the Inspector dock and saved to disk). To control the type of the exported property, use the type hint notation.

extends Node

enum Direction {LEFT, RIGHT, UP, DOWN}

# Built-in types.
@export var string = ""
@export var int_number = 5
@export var float_number: float = 5

# Enums.
@export var type: Variant.Type
@export var format: Image.Format
@export var direction: Direction

# Resources.
@export var image: Image
@export var custom_resource: CustomResource

# Nodes.
@export var node: Node
@export