Up to date

This page is up to date for Godot 4.1. If you still find outdated information, please open an issue.

@GlobalScope

Global scope constants and functions.

Description

A list of global scope enumerated constants and built-in functions. This is all that resides in the globals, constants regarding error codes, keycodes, property hints, etc.

Singletons are also documented here, since they can be accessed from anywhere.

For the entries related to GDScript which can be accessed in any script see @GDScript.

Tutorials

Properties

AudioServer

AudioServer

CameraServer

CameraServer

ClassDB

ClassDB

DisplayServer

DisplayServer

Engine

Engine

EngineDebugger

EngineDebugger

GDExtensionManager

GDExtensionManager

Geometry2D

Geometry2D

Geometry3D

Geometry3D

GodotSharp

GodotSharp

IP

IP

Input

Input

InputMap

InputMap

JavaClassWrapper

JavaClassWrapper

JavaScriptBridge

JavaScriptBridge

Marshalls

Marshalls

NavigationMeshGenerator

NavigationMeshGenerator

NavigationServer2D

NavigationServer2D

NavigationServer3D

NavigationServer3D

OS

OS

Performance

Performance

PhysicsServer2D

PhysicsServer2D

PhysicsServer2DManager

PhysicsServer2DManager

PhysicsServer3D

PhysicsServer3D

PhysicsServer3DManager

PhysicsServer3DManager

ProjectSettings

ProjectSettings

RenderingServer

RenderingServer

ResourceLoader

ResourceLoader

ResourceSaver

ResourceSaver

ResourceUID

ResourceUID

TextServerManager

TextServerManager

ThemeDB

ThemeDB

Time

Time

TranslationServer

TranslationServer

WorkerThreadPool

WorkerThreadPool

XRServer

XRServer

Methods

Variant

abs ( Variant x )

float

absf ( float x )

int

absi ( int x )

float

acos ( float x )

float

asin ( float x )

float

atan ( float x )

float

atan2 ( float y, float x )

float

bezier_derivative ( float start, float control_1, float control_2, float end, float t )

float

bezier_interpolate ( float start, float control_1, float control_2, float end, float t )

Variant

bytes_to_var ( PackedByteArray bytes )

Variant

bytes_to_var_with_objects ( PackedByteArray bytes )

Variant

ceil ( Variant x )

float

ceilf ( float x )

int

ceili ( float x )

Variant

clamp ( Variant value, Variant min, Variant max )

float

clampf ( float value, float min, float max )

int

clampi ( int value, int min, int max )

float

cos ( float angle_rad )

float

cosh ( float x )

float

cubic_interpolate ( float from, float to, float pre, float post, float weight )

float

cubic_interpolate_angle ( float from, float to, float pre, float post, float weight )

float

cubic_interpolate_angle_in_time ( float from, float to, float pre, float post, float weight, float to_t, float pre_t, float post_t )

float

cubic_interpolate_in_time ( float from, float to, float pre, float post, float weight, float to_t, float pre_t, float post_t )

float

db_to_linear ( float db )

float

deg_to_rad ( float deg )

float

ease ( float x, float curve )

String

error_string ( int error )

float

exp ( float x )

Variant

floor ( Variant x )

float

floorf ( float x )

int

floori ( float x )

float

fmod ( float x, float y )

float

fposmod ( float x, float y )

int

hash ( Variant variable )

Object

instance_from_id ( int instance_id )

float

inverse_lerp ( float from, float to, float weight )

bool

is_equal_approx ( float a, float b )

bool

is_finite ( float x )

bool

is_inf ( float x )

bool

is_instance_id_valid ( int id )

bool

is_instance_valid ( Variant instance )

bool

is_nan ( float x )

bool

is_same ( Variant a, Variant b )

bool

is_zero_approx ( float x )

Variant

lerp ( Variant from, Variant to, Variant weight )

float

lerp_angle ( float from, float to, float weight )

float

lerpf ( float from, float to, float weight )

float

linear_to_db ( float lin )

float

log ( float x )

Variant

max () vararg

float

maxf ( float a, float b )

int

maxi ( int a, int b )

Variant

min () vararg

float

minf ( float a, float b )

int

mini ( int a, int b )

float

move_toward ( float from, float to, float delta )

int

nearest_po2 ( int value )

float

pingpong ( float value, float length )

int

posmod ( int x, int y )

float

pow ( float base, float exp )

void

print () vararg

void

print_rich () vararg

void

print_verbose () vararg

void

printerr () vararg

void

printraw () vararg

void

prints () vararg

void

printt () vararg

void

push_error () vararg

void

push_warning () vararg

float

rad_to_deg ( float rad )

PackedInt64Array

rand_from_seed ( int seed )

float

randf ( )

float

randf_range ( float from, float to )

float

randfn ( float mean, float deviation )

int

randi ( )

int

randi_range ( int from, int to )

void

randomize ( )

float

remap ( float value, float istart, float istop, float ostart, float ostop )

int

rid_allocate_id ( )

RID

rid_from_int64 ( int base )

Variant

round ( Variant x )

float

roundf ( float x )

int

roundi ( float x )

void

seed ( int base )

Variant

sign ( Variant x )

float

signf ( float x )

int

signi ( int x )

float

sin ( float angle_rad )

float

sinh ( float x )

float

smoothstep ( float from, float to, float x )

Variant

snapped ( Variant x, Variant step )

float

snappedf ( float x, float step )

int

snappedi ( float x, int step )

float

sqrt ( float x )

int

step_decimals ( float x )

String

str () vararg

Variant

str_to_var ( String string )

float

tan ( float angle_rad )

float

tanh ( float x )

int

typeof ( Variant variable )

PackedByteArray

var_to_bytes ( Variant variable )

PackedByteArray

var_to_bytes_with_objects ( Variant variable )

String

var_to_str ( Variant variable )

Variant

weakref ( Variant obj )

Variant

wrap ( Variant value, Variant min, Variant max )

float

wrapf ( float value, float min, float max )

int

wrapi ( int value, int min, int max )


Enumerations

enum Side:

Side SIDE_LEFT = 0

Left side, usually used for Control or StyleBox-derived classes.

Side SIDE_TOP = 1

Top side, usually used for Control or StyleBox-derived classes.

Side SIDE_RIGHT = 2

Right side, usually used for Control or StyleBox-derived classes.

Side SIDE_BOTTOM = 3

Bottom side, usually used for Control or StyleBox-derived classes.


enum Corner:

Corner CORNER_TOP_LEFT = 0

Top-left corner.

Corner CORNER_TOP_RIGHT = 1

Top-right corner.

Corner CORNER_BOTTOM_RIGHT = 2

Bottom-right corner.

Corner CORNER_BOTTOM_LEFT = 3

Bottom-left corner.


enum Orientation:

Orientation VERTICAL = 1

General vertical alignment, usually used for Separator, ScrollBar, Slider, etc.

Orientation HORIZONTAL = 0

General horizontal alignment, usually used for Separator, ScrollBar, Slider, etc.


enum ClockDirection:

ClockDirection CLOCKWISE = 0

Clockwise rotation. Used by some methods (e.g. Image.rotate_90).

ClockDirection COUNTERCLOCKWISE = 1

Counter-clockwise rotation. Used by some methods (e.g. Image.rotate_90).


enum HorizontalAlignment:

HorizontalAlignment HORIZONTAL_ALIGNMENT_LEFT = 0

Horizontal left alignment, usually for text-derived classes.

HorizontalAlignment HORIZONTAL_ALIGNMENT_CENTER = 1

Horizontal center alignment, usually for text-derived classes.

HorizontalAlignment HORIZONTAL_ALIGNMENT_RIGHT = 2

Horizontal right alignment, usually for text-derived classes.

HorizontalAlignment HORIZONTAL_ALIGNMENT_FILL = 3

Expand row to fit width, usually for text-derived classes.


enum VerticalAlignment:

VerticalAlignment VERTICAL_ALIGNMENT_TOP = 0

Vertical top alignment, usually for text-derived classes.

VerticalAlignment VERTICAL_ALIGNMENT_CENTER = 1

Vertical center alignment, usually for text-derived classes.

VerticalAlignment VERTICAL_ALIGNMENT_BOTTOM = 2

Vertical bottom alignment, usually for text-derived classes.

VerticalAlignment VERTICAL_ALIGNMENT_FILL = 3

Expand rows to fit height, usually for text-derived classes.


enum InlineAlignment:

InlineAlignment INLINE_ALIGNMENT_TOP_TO = 0

Aligns the top of the inline object (e.g. image, table) to the position of the text specified by INLINE_ALIGNMENT_TO_* constant.

InlineAlignment INLINE_ALIGNMENT_CENTER_TO = 1

Aligns the center of the inline object (e.g. image, table) to the position of the text specified by INLINE_ALIGNMENT_TO_* constant.

InlineAlignment INLINE_ALIGNMENT_BASELINE_TO = 3

Aligns the baseline (user defined) of the inline object (e.g. image, table) to the position of the text specified by INLINE_ALIGNMENT_TO_* constant.

InlineAlignment INLINE_ALIGNMENT_BOTTOM_TO = 2

Aligns the bottom of the inline object (e.g. image, table) to the position of the text specified by INLINE_ALIGNMENT_TO_* constant.

InlineAlignment INLINE_ALIGNMENT_TO_TOP = 0

Aligns the position of the inline object (e.g. image, table) specified by INLINE_ALIGNMENT_*_TO constant to the top of the text.

InlineAlignment INLINE_ALIGNMENT_TO_CENTER = 4

Aligns the position of the inline object (e.g. image, table) specified by INLINE_ALIGNMENT_*_TO constant to the center of the text.

InlineAlignment INLINE_ALIGNMENT_TO_BASELINE = 8

Aligns the position of the inline object (e.g. image, table) specified by INLINE_ALIGNMENT_*_TO constant to the baseline of the text.

InlineAlignment INLINE_ALIGNMENT_TO_BOTTOM = 12

Aligns inline object (e.g. image, table) to the bottom of the text.

InlineAlignment INLINE_ALIGNMENT_TOP = 0

Aligns top of the inline object (e.g. image, table) to the top of the text. Equivalent to INLINE_ALIGNMENT_TOP_TO | INLINE_ALIGNMENT_TO_TOP.

InlineAlignment INLINE_ALIGNMENT_CENTER = 5

Aligns center of the inline object (e.g. image, table) to the center of the text. Equivalent to INLINE_ALIGNMENT_CENTER_TO | INLINE_ALIGNMENT_TO_CENTER.

InlineAlignment INLINE_ALIGNMENT_BOTTOM = 14

Aligns bottom of the inline object (e.g. image, table) to the bottom of the text. Equivalent to INLINE_ALIGNMENT_BOTTOM_TO | INLINE_ALIGNMENT_TO_BOTTOM.

InlineAlignment INLINE_ALIGNMENT_IMAGE_MASK = 3

A bit mask for INLINE_ALIGNMENT_*_TO alignment constants.

InlineAlignment INLINE_ALIGNMENT_TEXT_MASK = 12

A bit mask for INLINE_ALIGNMENT_TO_* alignment constants.


enum EulerOrder:

EulerOrder EULER_ORDER_XYZ = 0

Specifies that Euler angles should be in XYZ order. When composing, the order is X, Y, Z. When decomposing, the order is reversed, first Z, then Y, and X last.

EulerOrder EULER_ORDER_XZY = 1

Specifies that Euler angles should be in XZY order. When composing, the order is X, Z, Y. When decomposing, the order is reversed, first Y, then Z, and X last.

EulerOrder EULER_ORDER_YXZ = 2

Specifies that Euler angles should be in YXZ order. When composing, the order is Y, X, Z. When decomposing, the order is reversed, first Z, then X, and Y last.

EulerOrder EULER_ORDER_YZX = 3

Specifies that Euler angles should be in YZX order. When composing, the order is Y, Z, X. When decomposing, the order is reversed, first X, then Z, and Y last.

EulerOrder EULER_ORDER_ZXY = 4

Specifies that Euler angles should be in ZXY order. When composing, the order is Z, X, Y. When decomposing, the order is reversed, first Y, then X, and Z last.

EulerOrder EULER_ORDER_ZYX = 5

Specifies that Euler angles should be in ZYX order. When composing, the order is Z, Y, X. When decomposing, the order is reversed, first X, then Y, and Z last.


enum Key:

Key KEY_NONE = 0

Enum value which doesn’t correspond to any key. This is used to initialize Key properties with a generic state.

Key KEY_SPECIAL = 4194304

Keycodes with this bit applied are non-printable.

Key KEY_ESCAPE = 4194305

Escape key.

Key KEY_TAB = 4194306

Tab key.

Key KEY_BACKTAB = 4194307

Shift + Tab key.

Key KEY_BACKSPACE = 4194308

Backspace key.

Key KEY_ENTER = 4194309

Return key (on the main keyboard).

Key KEY_KP_ENTER = 4194310

Enter key on the numeric keypad.

Key KEY_INSERT = 4194311

Insert key.

Key KEY_DELETE = 4194312

Delete key.

Key KEY_PAUSE = 4194313

Pause key.

Key KEY_PRINT = 4194314

Print Screen key.

Key KEY_SYSREQ = 4194315

System Request key.

Key KEY_CLEAR = 4194316

Clear key.

Key KEY_HOME = 4194317

Home key.

Key KEY_END = 4194318

End key.

Key KEY_LEFT = 4194319

Left arrow key.

Key KEY_UP = 4194320

Up arrow key.

Key KEY_RIGHT = 4194321

Right arrow key.

Key KEY_DOWN = 4194322

Down arrow key.

Key KEY_PAGEUP = 4194323

Page Up key.

Key KEY_PAGEDOWN = 4194324

Page Down key.

Key KEY_SHIFT = 4194325

Shift key.

Key KEY_CTRL = 4194326

Control key.

Key KEY_META = 4194327

Meta key.

Key KEY_ALT = 4194328

Alt key.

Key KEY_CAPSLOCK = 4194329

Caps Lock key.

Key KEY_NUMLOCK = 4194330

Num Lock key.

Key KEY_SCROLLLOCK = 4194331

Scroll Lock key.

Key KEY_F1 = 4194332

F1 key.

Key KEY_F2 = 4194333

F2 key.

Key KEY_F3 = 4194334

F3 key.

Key KEY_F4 = 4194335

F4 key.

Key KEY_F5 = 4194336

F5 key.

Key KEY_F6 = 4194337

F6 key.

Key KEY_F7 = 4194338

F7 key.

Key KEY_F8 = 4194339

F8 key.

Key KEY_F9 = 4194340

F9 key.

Key KEY_F10 = 4194341

F10 key.

Key KEY_F11 = 4194342

F11 key.

Key KEY_F12 = 4194343

F12 key.

Key KEY_F13 = 4194344

F13 key.

Key KEY_F14 = 4194345

F14 key.

Key KEY_F15 = 4194346

F15 key.

Key KEY_F16 = 4194347

F16 key.

Key KEY_F17 = 4194348

F17 key.

Key KEY_F18 = 4194349

F18 key.

Key KEY_F19 = 4194350

F19 key.

Key KEY_F20 = 4194351

F20 key.

Key KEY_F21 = 4194352

F21 key.

Key KEY_F22 = 4194353

F22 key.

Key KEY_F23 = 4194354

F23 key.

Key KEY_F24 = 4194355

F24 key.

Key KEY_F25 = 4194356

F25 key. Only supported on macOS and Linux due to a Windows limitation.

Key KEY_F26 = 4194357

F26 key. Only supported on macOS and Linux due to a Windows limitation.

Key KEY_F27 = 4194358

F27 key. Only supported on macOS and Linux due to a Windows limitation.

Key KEY_F28 = 4194359

F28 key. Only supported on macOS and Linux due to a Windows limitation.

Key KEY_F29 = 4194360

F29 key. Only supported on macOS and Linux due to a Windows limitation.

Key KEY_F30 = 4194361

F30 key. Only supported on macOS and Linux due to a Windows limitation.

Key KEY_F31 = 4194362

F31 key. Only supported on macOS and Linux due to a Windows limitation.

Key KEY_F32 = 4194363

F32 key. Only supported on macOS and Linux due to a Windows limitation.

Key KEY_F33 = 4194364

F33 key. Only supported on macOS and Linux due to a Windows limitation.

Key KEY_F34 = 4194365

F34 key. Only supported on macOS and Linux due to a Windows limitation.

Key KEY_F35 = 4194366

F35 key. Only supported on macOS and Linux due to a Windows limitation.

Key KEY_KP_MULTIPLY = 4194433

Multiply (*) key on the numeric keypad.

Key KEY_KP_DIVIDE = 4194434

Divide (/) key on the numeric keypad.

Key KEY_KP_SUBTRACT = 4194435

Subtract (-) key on the numeric keypad.

Key KEY_KP_PERIOD = 4194436

Period (.) key on the numeric keypad.

Key KEY_KP_ADD = 4194437

Add (+) key on the numeric keypad.

Key KEY_KP_0 = 4194438

Number 0 on the numeric keypad.

Key KEY_KP_1 = 4194439

Number 1 on the numeric keypad.

Key KEY_KP_2 = 4194440

Number 2 on the numeric keypad.

Key KEY_KP_3 = 4194441

Number 3 on the numeric keypad.

Key KEY_KP_4 = 4194442

Number 4 on the numeric keypad.

Key KEY_KP_5 = 4194443

Number 5 on the numeric keypad.

Key KEY_KP_6 = 4194444

Number 6 on the numeric keypad.

Key KEY_KP_7 = 4194445

Number 7 on the numeric keypad.

Key KEY_KP_8 = 4194446

Number 8 on the numeric keypad.

Key KEY_KP_9 = 4194447

Number 9 on the numeric keypad.

Key KEY_MENU = 4194370

Context menu key.

Key KEY_HYPER = 4194371

Hyper key. (On Linux/X11 only).

Key KEY_HELP = 4194373

Help key.

Key KEY_BACK = 4194376

Media back key. Not to be confused with the Back button on an Android device.

Key KEY_FORWARD = 4194377

Media forward key.

Key KEY_STOP = 4194378

Media stop key.

Key KEY_REFRESH = 4194379

Media refresh key.

Key KEY_VOLUMEDOWN = 4194380

Volume down key.

Key KEY_VOLUMEMUTE = 4194381

Mute volume key.

Key KEY_VOLUMEUP = 4194382

Volume up key.

Key KEY_MEDIAPLAY = 4194388

Media play key.

Key KEY_MEDIASTOP = 4194389

Media stop key.

Key KEY_MEDIAPREVIOUS = 4194390

Previous song key.

Key KEY_MEDIANEXT = 4194391

Next song key.

Key KEY_MEDIARECORD = 4194392

Media record key.

Key KEY_HOMEPAGE = 4194393

Home page key.

Key KEY_FAVORITES = 4194394

Favorites key.

Key KEY_SEARCH = 4194395

Search key.

Key KEY_STANDBY = 4194396

Standby key.

Key KEY_OPENURL = 4194397

Open URL / Launch Browser key.

Key KEY_LAUNCHMAIL = 4194398

Launch Mail key.

Key KEY_LAUNCHMEDIA = 4194399

Launch Media key.

Key KEY_LAUNCH0 = 4194400

Launch Shortcut 0 key.

Key KEY_LAUNCH1 = 4194401

Launch Shortcut 1 key.

Key KEY_LAUNCH2 = 4194402

Launch Shortcut 2 key.

Key KEY_LAUNCH3 = 4194403

Launch Shortcut 3 key.

Key KEY_LAUNCH4 = 4194404

Launch Shortcut 4 key.

Key KEY_LAUNCH5 = 4194405

Launch Shortcut 5 key.

Key KEY_LAUNCH6 = 4194406

Launch Shortcut 6 key.

Key KEY_LAUNCH7 = 4194407

Launch Shortcut 7 key.

Key KEY_LAUNCH8 = 4194408

Launch Shortcut 8 key.

Key KEY_LAUNCH9 = 4194409

Launch Shortcut 9 key.

Key KEY_LAUNCHA = 4194410

Launch Shortcut A key.

Key KEY_LAUNCHB = 4194411

Launch Shortcut B key.

Key KEY_LAUNCHC = 4194412

Launch Shortcut C key.

Key KEY_LAUNCHD = 4194413

Launch Shortcut D key.

Key KEY_LAUNCHE = 4194414

Launch Shortcut E key.

Key KEY_LAUNCHF = 4194415

Launch Shortcut F key.

Key KEY_UNKNOWN = 8388607

Unknown key.

Key KEY_SPACE = 32

Space key.

Key KEY_EXCLAM = 33

! key.

Key KEY_QUOTEDBL = 34

“ key.

Key KEY_NUMBERSIGN = 35

# key.

Key KEY_DOLLAR = 36

$ key.

Key KEY_PERCENT = 37

% key.

Key KEY_AMPERSAND = 38

& key.

Key KEY_APOSTROPHE = 39

‘ key.

Key KEY_PARENLEFT = 40

( key.

Key KEY_PARENRIGHT = 41

) key.

Key KEY_ASTERISK = 42

* key.

Key KEY_PLUS = 43

  • key.

Key KEY_COMMA = 44

, key.

Key KEY_MINUS = 45

  • key.

Key KEY_PERIOD = 46

. key.

Key KEY_SLASH = 47

/ key.

Key KEY_0 = 48

Number 0 key.

Key KEY_1 = 49

Number 1 key.

Key KEY_2 = 50

Number 2 key.

Key KEY_3 = 51

Number 3 key.

Key KEY_4 = 52

Number 4 key.

Key KEY_5 = 53

Number 5 key.

Key KEY_6 = 54

Number 6 key.

Key KEY_7 = 55

Number 7 key.

Key KEY_8 = 56

Number 8 key.

Key KEY_9 = 57

Number 9 key.

Key KEY_COLON = 58

: key.

Key KEY_SEMICOLON = 59

; key.

Key KEY_LESS = 60

< key.

Key KEY_EQUAL = 61

\= key.

Key KEY_GREATER = 62

> key.

Key KEY_QUESTION = 63

? key.

Key KEY_AT = 64

@ key.

Key KEY_A = 65

A key.

Key KEY_B = 66

B key.

Key KEY_C = 67

C key.

Key KEY_D = 68

D key.

Key KEY_E = 69

E key.

Key KEY_F = 70

F key.

Key KEY_G = 71

G key.

Key KEY_H = 72

H key.

Key KEY_I = 73

I key.

Key KEY_J = 74

J key.

Key KEY_K = 75

K key.

Key KEY_L = 76

L key.

Key KEY_M = 77

M key.

Key KEY_N = 78

N key.

Key KEY_O = 79

O key.

Key KEY_P = 80

P key.

Key KEY_Q = 81

Q key.

Key KEY_R = 82

R key.

Key KEY_S = 83

S key.

Key KEY_T = 84

T key.

Key KEY_U = 85

U key.

Key KEY_V = 86

V key.

Key KEY_W = 87

W key.

Key KEY_X = 88

X key.

Key KEY_Y = 89

Y key.

Key KEY_Z = 90

Z key.

Key KEY_BRACKETLEFT = 91

[ key.

Key KEY_BACKSLASH = 92

\ key.

Key KEY_BRACKETRIGHT = 93

] key.

Key KEY_ASCIICIRCUM = 94

^ key.

Key KEY_UNDERSCORE = 95

_ key.

Key KEY_QUOTELEFT = 96

` key.

Key KEY_BRACELEFT = 123

{ key.

Key KEY_BAR = 124

key.

Key KEY_BRACERIGHT = 125

} key.

Key KEY_ASCIITILDE = 126

~ key.

Key KEY_YEN = 165

¥ key.

Key KEY_SECTION = 167

§ key.

Key KEY_GLOBE = 4194416

“Globe” key on Mac / iPad keyboard.

Key KEY_KEYBOARD = 4194417

“On-screen keyboard” key iPad keyboard.

Key KEY_JIS_EISU = 4194418

英数 key on Mac keyboard.

Key KEY_JIS_KANA = 4194419

かな key on Mac keyboard.


flags KeyModifierMask:

KeyModifierMask KEY_CODE_MASK = 8388607

Key Code mask.

KeyModifierMask KEY_MODIFIER_MASK = 532676608

Modifier key mask.

KeyModifierMask KEY_MASK_CMD_OR_CTRL = 16777216

Automatically remapped to KEY_META on macOS and KEY_CTRL on other platforms, this mask is never set in the actual events, and should be used for key mapping only.

KeyModifierMask KEY_MASK_SHIFT = 33554432

Shift key mask.

KeyModifierMask KEY_MASK_ALT = 67108864

Alt or Option (on macOS) key mask.

KeyModifierMask KEY_MASK_META = 134217728

Command (on macOS) or Meta/Windows key mask.

KeyModifierMask KEY_MASK_CTRL = 268435456

Control key mask.

KeyModifierMask KEY_MASK_KPAD = 536870912

Keypad key mask.

KeyModifierMask KEY_MASK_GROUP_SWITCH = 1073741824

Group Switch key mask.


enum MouseButton:

MouseButton MOUSE_BUTTON_NONE = 0

Enum value which doesn’t correspond to any mouse button. This is used to initialize MouseButton properties with a generic state.

MouseButton MOUSE_BUTTON_LEFT = 1

Primary mouse button, usually assigned to the left button.

MouseButton MOUSE_BUTTON_RIGHT = 2

Secondary mouse button, usually assigned to the right button.

MouseButton MOUSE_BUTTON_MIDDLE = 3

Middle mouse button.

MouseButton MOUSE_BUTTON_WHEEL_UP = 4

Mouse wheel scrolling up.

MouseButton MOUSE_BUTTON_WHEEL_DOWN = 5

Mouse wheel scrolling down.

MouseButton MOUSE_BUTTON_WHEEL_LEFT = 6

Mouse wheel left button (only present on some mice).

MouseButton MOUSE_BUTTON_WHEEL_RIGHT = 7

Mouse wheel right button (only present on some mice).

MouseButton MOUSE_BUTTON_XBUTTON1 = 8

Extra mouse button 1. This is sometimes present, usually to the sides of the mouse.

MouseButton MOUSE_BUTTON_XBUTTON2 = 9

Extra mouse button 2. This is sometimes present, usually to the sides of the mouse.


flags MouseButtonMask:

MouseButtonMask MOUSE_BUTTON_MASK_LEFT = 1

Primary mouse button mask, usually for the left button.

MouseButtonMask MOUSE_BUTTON_MASK_RIGHT = 2

Secondary mouse button mask, usually for the right button.

MouseButtonMask MOUSE_BUTTON_MASK_MIDDLE = 4

Middle mouse button mask.

MouseButtonMask MOUSE_BUTTON_MASK_MB_XBUTTON1 = 128

Extra mouse button 1 mask.

MouseButtonMask MOUSE_BUTTON_MASK_MB_XBUTTON2 = 256

Extra mouse button 2 mask.


enum JoyButton:

JoyButton JOY_BUTTON_INVALID = -1

An invalid game controller button.

JoyButton JOY_BUTTON_A = 0

Game controller SDL button A. Corresponds to the bottom action button: Sony Cross, Xbox A, Nintendo B.

JoyButton JOY_BUTTON_B = 1

Game controller SDL button B. Corresponds to the right action button: Sony Circle, Xbox B, Nintendo A.

JoyButton JOY_BUTTON_X = 2

Game controller SDL button X. Corresponds to the left action button: Sony Square, Xbox X, Nintendo Y.

JoyButton JOY_BUTTON_Y = 3

Game controller SDL button Y. Corresponds to the top action button: Sony Triangle, Xbox Y, Nintendo X.

JoyButton JOY_BUTTON_BACK = 4

Game controller SDL back button. Corresponds to the Sony Select, Xbox Back, Nintendo - button.

JoyButton JOY_BUTTON_GUIDE = 5

Game controller SDL guide button. Corresponds to the Sony PS, Xbox Home button.

JoyButton JOY_BUTTON_START = 6

Game controller SDL start button. Corresponds to the Nintendo + button.

JoyButton JOY_BUTTON_LEFT_STICK = 7

Game controller SDL left stick button. Corresponds to the Sony L3, Xbox L/LS button.

JoyButton JOY_BUTTON_RIGHT_STICK = 8

Game controller SDL right stick button. Corresponds to the Sony R3, Xbox R/RS button.

JoyButton JOY_BUTTON_LEFT_SHOULDER = 9

Game controller SDL left shoulder button. Corresponds to the Sony L1, Xbox LB button.

JoyButton JOY_BUTTON_RIGHT_SHOULDER = 10

Game controller SDL right shoulder button. Corresponds to the Sony R1, Xbox RB button.

JoyButton JOY_BUTTON_DPAD_UP = 11

Game controller D-pad up button.

JoyButton JOY_BUTTON_DPAD_DOWN = 12

Game controller D-pad down button.

JoyButton JOY_BUTTON_DPAD_LEFT = 13

Game controller D-pad left button.

JoyButton JOY_BUTTON_DPAD_RIGHT = 14

Game controller D-pad right button.

JoyButton JOY_BUTTON_MISC1 = 15

Game controller SDL miscellaneous button. Corresponds to Xbox share button, PS5 microphone button, Nintendo Switch capture button.

JoyButton JOY_BUTTON_PADDLE1 = 16

Game controller SDL paddle 1 button.

JoyButton JOY_BUTTON_PADDLE2 = 17

Game controller SDL paddle 2 button.

JoyButton JOY_BUTTON_PADDLE3 = 18

Game controller SDL paddle 3 button.

JoyButton JOY_BUTTON_PADDLE4 = 19

Game controller SDL paddle 4 button.

JoyButton JOY_BUTTON_TOUCHPAD = 20

Game controller SDL touchpad button.

JoyButton JOY_BUTTON_SDL_MAX = 21

The number of SDL game controller buttons.

JoyButton JOY_BUTTON_MAX = 128

The maximum number of game controller buttons supported by the engine. The actual limit may be lower on specific platforms:

  • Android: Up to 36 buttons.

  • Linux: Up to 80 buttons.

  • Windows and macOS: Up to 128 buttons.


enum JoyAxis:

JoyAxis JOY_AXIS_INVALID = -1

An invalid game controller axis.

JoyAxis JOY_AXIS_LEFT_X = 0

Game controller left joystick x-axis.

JoyAxis JOY_AXIS_LEFT_Y = 1

Game controller left joystick y-axis.

JoyAxis JOY_AXIS_RIGHT_X = 2

Game controller right joystick x-axis.

JoyAxis JOY_AXIS_RIGHT_Y = 3

Game controller right joystick y-axis.

JoyAxis JOY_AXIS_TRIGGER_LEFT = 4

Game controller left trigger axis.

JoyAxis JOY_AXIS_TRIGGER_RIGHT = 5

Game controller right trigger axis.

JoyAxis JOY_AXIS_SDL_MAX = 6

The number of SDL game controller axes.

JoyAxis JOY_AXIS_MAX = 10

The maximum number of game controller axes: OpenVR supports up to 5 Joysticks making a total of 10 axes.


enum MIDIMessage:

MIDIMessage MIDI_MESSAGE_NONE = 0

Enum value which doesn’t correspond to any MIDI message. This is used to initialize MIDIMessage properties with a generic state.

MIDIMessage MIDI_MESSAGE_NOTE_OFF = 8

MIDI note OFF message. Not all MIDI devices send this event; some send MIDI_MESSAGE_NOTE_ON with zero velocity instead. See the documentation of InputEventMIDI for information of how to use MIDI inputs.

MIDIMessage MIDI_MESSAGE_NOTE_ON = 9

MIDI note ON message. Some MIDI devices send this event with velocity zero instead of MIDI_MESSAGE_NOTE_OFF, but implementations vary. See the documentation of InputEventMIDI for information of how to use MIDI inputs.

MIDIMessage MIDI_MESSAGE_AFTERTOUCH = 10

MIDI aftertouch message. This message is most often sent by pressing down on the key after it “bottoms out”.

MIDIMessage MIDI_MESSAGE_CONTROL_CHANGE = 11

MIDI control change message. This message is sent when a controller value changes. Controllers include devices such as pedals and levers.

MIDIMessage MIDI_MESSAGE_PROGRAM_CHANGE = 12

MIDI program change message. This message sent when the program patch number changes.

MIDIMessage MIDI_MESSAGE_CHANNEL_PRESSURE = 13

MIDI channel pressure message. This message is most often sent by pressing down on the key after it “bottoms out”. This message is different from polyphonic after-touch as it indicates the highest pressure across all keys.

MIDIMessage MIDI_MESSAGE_PITCH_BEND = 14

MIDI pitch bend message. This message is sent to indicate a change in the pitch bender (wheel or lever, typically).

MIDIMessage MIDI_MESSAGE_SYSTEM_EXCLUSIVE = 240

MIDI system exclusive message. This has behavior exclusive to the device you’re receiving input from. Getting this data is not implemented in Godot.

MIDIMessage MIDI_MESSAGE_QUARTER_FRAME = 241

MIDI quarter frame message. Contains timing information that is used to synchronize MIDI devices. Getting this data is not implemented in Godot.

MIDIMessage MIDI_MESSAGE_SONG_POSITION_POINTER = 242

MIDI song position pointer message. Gives the number of 16th notes since the start of the song. Getting this data is not implemented in Godot.

MIDIMessage MIDI_MESSAGE_SONG_SELECT = 243

MIDI song select message. Specifies which sequence or song is to be played. Getting this data is not implemented in Godot.

MIDIMessage MIDI_MESSAGE_TUNE_REQUEST = 246

MIDI tune request message. Upon receiving a tune request, all analog synthesizers should tune their oscillators.

MIDIMessage MIDI_MESSAGE_TIMING_CLOCK = 248

MIDI timing clock message. Sent 24 times per quarter note when synchronization is required.

MIDIMessage MIDI_MESSAGE_START = 250

MIDI start message. Start the current sequence playing. This message will be followed with Timing Clocks.

MIDIMessage MIDI_MESSAGE_CONTINUE = 251

MIDI continue message. Continue at the point the sequence was stopped.

MIDIMessage MIDI_MESSAGE_STOP = 252

MIDI stop message. Stop the current sequence.

MIDIMessage MIDI_MESSAGE_ACTIVE_SENSING = 254

MIDI active sensing message. This message is intended to be sent repeatedly to tell the receiver that a connection is alive.

MIDIMessage MIDI_MESSAGE_SYSTEM_RESET = 255

MIDI system reset message. Reset all receivers in the system to power-up status. It should not be sent on power-up itself.


enum Error:

Error OK = 0

Methods that return Error return OK when no error occurred.

Since OK has value 0, and all other error constants are positive integers, it can also be used in boolean checks.

Example:

  1. var error = method_that_returns_error()
  2. if error != OK:
  3. printerr("Failure!")
  4. # Or, alternatively:
  5. if error:
  6. printerr("Still failing!")

Note: Many functions do not return an error code, but will print error messages to standard output.

Error FAILED = 1

Generic error.

Error ERR_UNAVAILABLE = 2

Unavailable error.

Error ERR_UNCONFIGURED = 3

Unconfigured error.

Error ERR_UNAUTHORIZED = 4

Unauthorized error.

Error ERR_PARAMETER_RANGE_ERROR = 5

Parameter range error.

Error ERR_OUT_OF_MEMORY = 6

Out of memory (OOM) error.

Error ERR_FILE_NOT_FOUND = 7

File: Not found error.

Error ERR_FILE_BAD_DRIVE = 8

File: Bad drive error.

Error ERR_FILE_BAD_PATH = 9

File: Bad path error.

Error ERR_FILE_NO_PERMISSION = 10

File: No permission error.

Error ERR_FILE_ALREADY_IN_USE = 11

File: Already in use error.

Error ERR_FILE_CANT_OPEN = 12

File: Can’t open error.

Error ERR_FILE_CANT_WRITE = 13

File: Can’t write error.

Error ERR_FILE_CANT_READ = 14

File: Can’t read error.

Error ERR_FILE_UNRECOGNIZED = 15

File: Unrecognized error.

Error ERR_FILE_CORRUPT = 16

File: Corrupt error.

Error ERR_FILE_MISSING_DEPENDENCIES = 17

File: Missing dependencies error.

Error ERR_FILE_EOF = 18

File: End of file (EOF) error.

Error ERR_CANT_OPEN = 19

Can’t open error.

Error ERR_CANT_CREATE = 20

Can’t create error.

Error ERR_QUERY_FAILED = 21

Query failed error.

Error ERR_ALREADY_IN_USE = 22

Already in use error.

Error ERR_LOCKED = 23

Locked error.

Error ERR_TIMEOUT = 24

Timeout error.

Error ERR_CANT_CONNECT = 25

Can’t connect error.

Error ERR_CANT_RESOLVE = 26

Can’t resolve error.

Error ERR_CONNECTION_ERROR = 27

Connection error.

Error ERR_CANT_ACQUIRE_RESOURCE = 28

Can’t acquire resource error.

Error ERR_CANT_FORK = 29

Can’t fork process error.

Error ERR_INVALID_DATA = 30

Invalid data error.

Error ERR_INVALID_PARAMETER = 31

Invalid parameter error.

Error ERR_ALREADY_EXISTS = 32

Already exists error.

Error ERR_DOES_NOT_EXIST = 33

Does not exist error.

Error ERR_DATABASE_CANT_READ = 34

Database: Read error.

Error ERR_DATABASE_CANT_WRITE = 35

Database: Write error.

Error ERR_COMPILATION_FAILED = 36

Compilation failed error.

Error ERR_METHOD_NOT_FOUND = 37

Method not found error.

Error ERR_LINK_FAILED = 38

Linking failed error.

Error ERR_SCRIPT_FAILED = 39

Script failed error.

Error ERR_CYCLIC_LINK = 40

Cycling link (import cycle) error.

Error ERR_INVALID_DECLARATION = 41

Invalid declaration error.

Error ERR_DUPLICATE_SYMBOL = 42

Duplicate symbol error.

Error ERR_PARSE_ERROR = 43

Parse error.

Error ERR_BUSY = 44

Busy error.

Error ERR_SKIP = 45

Skip error.

Error ERR_HELP = 46

Help error. Used internally when passing --version or --help as executable options.

Error ERR_BUG = 47

Bug error, caused by an implementation issue in the method.

Note: If a built-in method returns this code, please open an issue on the GitHub Issue Tracker.

Error ERR_PRINTER_ON_FIRE = 48

Printer on fire error (This is an easter egg, no built-in methods return this error code).


enum PropertyHint:

PropertyHint PROPERTY_HINT_NONE = 0

The property has no hint for the editor.

PropertyHint PROPERTY_HINT_RANGE = 1

Hints that an int or float property should be within a range specified via the hint string "min,max" or "min,max,step". The hint string can optionally include "or_greater" and/or "or_less" to allow manual input going respectively above the max or below the min values.

Example: "-360,360,1,or_greater,or_less".

Additionally, other keywords can be included: "exp" for exponential range editing, "radians" for editing radian angles in degrees, "degrees" to hint at an angle and "hide_slider" to hide the slider.

PropertyHint PROPERTY_HINT_ENUM = 2

Hints that an int or String property is an enumerated value to pick in a list specified via a hint string.

The hint string is a comma separated list of names such as "Hello,Something,Else". Whitespaces are not removed from either end of a name. For integer properties, the first name in the list has value 0, the next 1, and so on. Explicit values can also be specified by appending :integer to the name, e.g. "Zero,One,Three:3,Four,Six:6".

PropertyHint PROPERTY_HINT_ENUM_SUGGESTION = 3

Hints that a String property can be an enumerated value to pick in a list specified via a hint string such as "Hello,Something,Else".

Unlike PROPERTY_HINT_ENUM, a property with this hint still accepts arbitrary values and can be empty. The list of values serves to suggest possible values.

PropertyHint PROPERTY_HINT_EXP_EASING = 4

Hints that a float property should be edited via an exponential easing function. The hint string can include "attenuation" to flip the curve horizontally and/or "positive_only" to exclude in/out easing and limit values to be greater than or equal to zero.

PropertyHint PROPERTY_HINT_LINK = 5

Hints that a vector property should allow its components to be linked. For example, this allows Vector2.x and Vector2.y to be edited together.

PropertyHint PROPERTY_HINT_FLAGS = 6

Hints that an int property is a bitmask with named bit flags.

The hint string is a comma separated list of names such as "Bit0,Bit1,Bit2,Bit3". Whitespaces are not removed from either end of a name. The first name in the list has value 1, the next 2, then 4, 8, 16 and so on. Explicit values can also be specified by appending :integer to the name, e.g. "A:4,B:8,C:16". You can also combine several flags ("A:4,B:8,AB:12,C:16").

Note: A flag value must be at least 1 and at most 2 ** 32 - 1.

Note: Unlike PROPERTY_HINT_ENUM, the previous explicit value is not taken into account. For the hint "A:16,B,C", A is 16, B is 2, C is 4.

PropertyHint PROPERTY_HINT_LAYERS_2D_RENDER = 7

Hints that an int property is a bitmask using the optionally named 2D render layers.

PropertyHint PROPERTY_HINT_LAYERS_2D_PHYSICS = 8

Hints that an int property is a bitmask using the optionally named 2D physics layers.

PropertyHint PROPERTY_HINT_LAYERS_2D_NAVIGATION = 9

Hints that an int property is a bitmask using the optionally named 2D navigation layers.

PropertyHint PROPERTY_HINT_LAYERS_3D_RENDER = 10

Hints that an int property is a bitmask using the optionally named 3D render layers.

PropertyHint PROPERTY_HINT_LAYERS_3D_PHYSICS = 11

Hints that an int property is a bitmask using the optionally named 3D physics layers.

PropertyHint PROPERTY_HINT_LAYERS_3D_NAVIGATION = 12

Hints that an int property is a bitmask using the optionally named 3D navigation layers.

PropertyHint PROPERTY_HINT_LAYERS_AVOIDANCE = 37

Hints that an integer property is a bitmask using the optionally named avoidance layers.

PropertyHint PROPERTY_HINT_FILE = 13

Hints that a String property is a path to a file. Editing it will show a file dialog for picking the path. The hint string can be a set of filters with wildcards like "*.png,*.jpg".

PropertyHint PROPERTY_HINT_DIR = 14

Hints that a String property is a path to a directory. Editing it will show a file dialog for picking the path.

PropertyHint PROPERTY_HINT_GLOBAL_FILE = 15

Hints that a String property is an absolute path to a file outside the project folder. Editing it will show a file dialog for picking the path. The hint string can be a set of filters with wildcards, like "*.png,*.jpg".

PropertyHint PROPERTY_HINT_GLOBAL_DIR = 16

Hints that a String property is an absolute path to a directory outside the project folder. Editing it will show a file dialog for picking the path.

PropertyHint PROPERTY_HINT_RESOURCE_TYPE = 17

Hints that a property is an instance of a Resource-derived type, optionally specified via the hint string (e.g. "Texture2D"). Editing it will show a popup menu of valid resource types to instantiate.

PropertyHint PROPERTY_HINT_MULTILINE_TEXT = 18

Hints that a String property is text with line breaks. Editing it will show a text input field where line breaks can be typed.

PropertyHint PROPERTY_HINT_EXPRESSION = 19

Hints that a String property is an Expression.

PropertyHint PROPERTY_HINT_PLACEHOLDER_TEXT = 20

Hints that a String property should show a placeholder text on its input field, if empty. The hint string is the placeholder text to use.

PropertyHint PROPERTY_HINT_COLOR_NO_ALPHA = 21

Hints that a Color property should be edited without affecting its transparency (Color.a is not editable).

PropertyHint PROPERTY_HINT_OBJECT_ID = 22

PropertyHint PROPERTY_HINT_TYPE_STRING = 23

If a property is String, hints that the property represents a particular type (class). This allows to select a type from the create dialog. The property will store the selected type as a string.

If a property is Array, hints the editor how to show elements. The hint_string must encode nested types using ":" and "/".

GDScriptC#

  1. # Array of elem_type.
  2. hint_string = "%d:" % [elem_type]
  3. hint_string = "%d/%d:%s" % [elem_type, elem_hint, elem_hint_string]
  4. # Two-dimensional array of elem_type (array of arrays of elem_type).
  5. hint_string = "%d:%d:" % [TYPE_ARRAY, elem_type]
  6. hint_string = "%d:%d/%d:%s" % [TYPE_ARRAY, elem_type, elem_hint, elem_hint_string]
  7. # Three-dimensional array of elem_type (array of arrays of arrays of elem_type).
  8. hint_string = "%d:%d:%d:" % [TYPE_ARRAY, TYPE_ARRAY, elem_type]
  9. hint_string = "%d:%d:%d/%d:%s" % [TYPE_ARRAY, TYPE_ARRAY, elem_type, elem_hint, elem_hint_string]
  1. // Array of elemType.
  2. hintString = $"{elemType:D}:";
  3. hintString = $"{elemType:}/{elemHint:D}:{elemHintString}";
  4. // Two-dimensional array of elemType (array of arrays of elemType).
  5. hintString = $"{Variant.Type.Array:D}:{elemType:D}:";
  6. hintString = $"{Variant.Type.Array:D}:{elemType:D}/{elemHint:D}:{elemHintString}";
  7. // Three-dimensional array of elemType (array of arrays of arrays of elemType).
  8. hintString = $"{Variant.Type.Array:D}:{Variant.Type.Array:D}:{elemType:D}:";
  9. hintString = $"{Variant.Type.Array:D}:{Variant.Type.Array:D}:{elemType:D}/{elemHint:D}:{elemHintString}";

Examples:

GDScriptC#

  1. hint_string = "%d:" % [TYPE_INT] # Array of integers.
  2. hint_string = "%d/%d:1,10,1" % [TYPE_INT, PROPERTY_HINT_RANGE] # Array of integers (in range from 1 to 10).
  3. hint_string = "%d/%d:Zero,One,Two" % [TYPE_INT, PROPERTY_HINT_ENUM] # Array of integers (an enum).
  4. hint_string = "%d/%d:Zero,One,Three:3,Six:6" % [TYPE_INT, PROPERTY_HINT_ENUM] # Array of integers (an enum).
  5. hint_string = "%d/%d:*.png" % [TYPE_STRING, PROPERTY_HINT_FILE] # Array of strings (file paths).
  6. hint_string = "%d/%d:Texture2D" % [TYPE_OBJECT, PROPERTY_HINT_RESOURCE_TYPE] # Array of textures.
  7. hint_string = "%d:%d:" % [TYPE_ARRAY, TYPE_FLOAT] # Two-dimensional array of floats.
  8. hint_string = "%d:%d/%d:" % [TYPE_ARRAY, TYPE_STRING, PROPERTY_HINT_MULTILINE_TEXT] # Two-dimensional array of multiline strings.
  9. hint_string = "%d:%d/%d:-1,1,0.1" % [TYPE_ARRAY, TYPE_FLOAT, PROPERTY_HINT_RANGE] # Two-dimensional array of floats (in range from -1 to 1).
  10. hint_string = "%d:%d/%d:Texture2D" % [TYPE_ARRAY, TYPE_OBJECT, PROPERTY_HINT_RESOURCE_TYPE] # Two-dimensional array of textures.
  1. hintString = $"{Variant.Type.Int:D}/{PropertyHint.Range:D}:1,10,1"; // Array of integers (in range from 1 to 10).
  2. hintString = $"{Variant.Type.Int:D}/{PropertyHint.Enum:D}:Zero,One,Two"; // Array of integers (an enum).
  3. hintString = $"{Variant.Type.Int:D}/{PropertyHint.Enum:D}:Zero,One,Three:3,Six:6"; // Array of integers (an enum).
  4. hintString = $"{Variant.Type.String:D}/{PropertyHint.File:D}:*.png"; // Array of strings (file paths).
  5. hintString = $"{Variant.Type.Object:D}/{PropertyHint.ResourceType:D}:Texture2D"; // Array of textures.
  6. hintString = $"{Variant.Type.Array:D}:{Variant.Type.Float:D}:"; // Two-dimensional array of floats.
  7. hintString = $"{Variant.Type.Array:D}:{Variant.Type.String:D}/{PropertyHint.MultilineText:D}:"; // Two-dimensional array of multiline strings.
  8. hintString = $"{Variant.Type.Array:D}:{Variant.Type.Float:D}/{PropertyHint.Range:D}:-1,1,0.1"; // Two-dimensional array of floats (in range from -1 to 1).
  9. hintString = $"{Variant.Type.Array:D}:{Variant.Type.Object:D}/{PropertyHint.ResourceType:D}:Texture2D"; // Two-dimensional array of textures.

Note: The trailing colon is required for properly detecting built-in types.

PropertyHint PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE = 24

PropertyHint PROPERTY_HINT_OBJECT_TOO_BIG = 25

PropertyHint PROPERTY_HINT_NODE_PATH_VALID_TYPES = 26

PropertyHint PROPERTY_HINT_SAVE_FILE = 27

PropertyHint PROPERTY_HINT_GLOBAL_SAVE_FILE = 28

PropertyHint PROPERTY_HINT_INT_IS_OBJECTID = 29

PropertyHint PROPERTY_HINT_INT_IS_POINTER = 30

PropertyHint PROPERTY_HINT_ARRAY_TYPE = 31

PropertyHint PROPERTY_HINT_LOCALE_ID = 32

Hints that a string property is a locale code. Editing it will show a locale dialog for picking language and country.

PropertyHint PROPERTY_HINT_LOCALIZABLE_STRING = 33

Hints that a dictionary property is string translation map. Dictionary keys are locale codes and, values are translated strings.

PropertyHint PROPERTY_HINT_NODE_TYPE = 34

PropertyHint PROPERTY_HINT_HIDE_QUATERNION_EDIT = 35

Hints that a quaternion property should disable the temporary euler editor.

PropertyHint PROPERTY_HINT_PASSWORD = 36

Hints that a string property is a password, and every character is replaced with the secret character.

PropertyHint PROPERTY_HINT_MAX = 38

Represents the size of the PropertyHint enum.


flags PropertyUsageFlags:

PropertyUsageFlags PROPERTY_USAGE_NONE = 0

The property is not stored, and does not display in the editor. This is the default for non-exported properties.

PropertyUsageFlags PROPERTY_USAGE_STORAGE = 2

The property is serialized and saved in the scene file (default).

PropertyUsageFlags PROPERTY_USAGE_EDITOR = 4

The property is shown in the EditorInspector (default).

PropertyUsageFlags PROPERTY_USAGE_INTERNAL = 8

The property is excluded from the class reference.

PropertyUsageFlags PROPERTY_USAGE_CHECKABLE = 16

The property can be checked in the EditorInspector.

PropertyUsageFlags PROPERTY_USAGE_CHECKED = 32

The property is checked in the EditorInspector.

PropertyUsageFlags PROPERTY_USAGE_GROUP = 64

Used to group properties together in the editor. See EditorInspector.

PropertyUsageFlags PROPERTY_USAGE_CATEGORY = 128

Used to categorize properties together in the editor.

PropertyUsageFlags PROPERTY_USAGE_SUBGROUP = 256

Used to group properties together in the editor in a subgroup (under a group). See EditorInspector.

PropertyUsageFlags PROPERTY_USAGE_CLASS_IS_BITFIELD = 512

PropertyUsageFlags PROPERTY_USAGE_NO_INSTANCE_STATE = 1024

The property does not save its state in PackedScene.

PropertyUsageFlags PROPERTY_USAGE_RESTART_IF_CHANGED = 2048

Editing the property prompts the user for restarting the editor.

PropertyUsageFlags PROPERTY_USAGE_SCRIPT_VARIABLE = 4096

The property is a script variable which should be serialized and saved in the scene file.

PropertyUsageFlags PROPERTY_USAGE_STORE_IF_NULL = 8192

PropertyUsageFlags PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 16384

PropertyUsageFlags PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE = 32768

PropertyUsageFlags PROPERTY_USAGE_CLASS_IS_ENUM = 65536

PropertyUsageFlags PROPERTY_USAGE_NIL_IS_VARIANT = 131072

PropertyUsageFlags PROPERTY_USAGE_ARRAY = 262144

The property is an array.

PropertyUsageFlags PROPERTY_USAGE_ALWAYS_DUPLICATE = 524288

When duplicating a resource with Resource.duplicate, and this flag is set on a property of that resource, the property should always be duplicated, regardless of the subresources bool parameter.

PropertyUsageFlags PROPERTY_USAGE_NEVER_DUPLICATE = 1048576

When duplicating a resource with Resource.duplicate, and this flag is set on a property of that resource, the property should never be duplicated, regardless of the subresources bool parameter.

PropertyUsageFlags PROPERTY_USAGE_HIGH_END_GFX = 2097152

The property is only shown in the editor if modern renderers are supported (the Compatibility rendering method is excluded).

PropertyUsageFlags PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT = 4194304

PropertyUsageFlags PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT = 8388608

PropertyUsageFlags PROPERTY_USAGE_KEYING_INCREMENTS = 16777216

PropertyUsageFlags PROPERTY_USAGE_DEFERRED_SET_RESOURCE = 33554432

PropertyUsageFlags PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT = 67108864

PropertyUsageFlags PROPERTY_USAGE_EDITOR_BASIC_SETTING = 134217728

PropertyUsageFlags PROPERTY_USAGE_READ_ONLY = 268435456

The property is read-only in the EditorInspector.

PropertyUsageFlags PROPERTY_USAGE_SECRET = 536870912

An export preset property with this flag contains confidential information and is stored separately from the rest of the export preset configuration.

PropertyUsageFlags PROPERTY_USAGE_DEFAULT = 6

Default usage (storage and editor).

PropertyUsageFlags PROPERTY_USAGE_NO_EDITOR = 2

Default usage but without showing the property in the editor (storage).


flags MethodFlags:

MethodFlags METHOD_FLAG_NORMAL = 1

Flag for a normal method.

MethodFlags METHOD_FLAG_EDITOR = 2

Flag for an editor method.

MethodFlags METHOD_FLAG_CONST = 4

Flag for a constant method.

MethodFlags METHOD_FLAG_VIRTUAL = 8

Flag for a virtual method.

MethodFlags METHOD_FLAG_VARARG = 16

Flag for a method with a variable number of arguments.

MethodFlags METHOD_FLAG_STATIC = 32

Flag for a static method.

MethodFlags METHOD_FLAG_OBJECT_CORE = 64

Used internally. Allows to not dump core virtual methods (such as Object._notification) to the JSON API.

MethodFlags METHOD_FLAGS_DEFAULT = 1

Default method flags (normal).


enum Variant.Type:

Variant.Type TYPE_NIL = 0

Variable is null.

Variant.Type TYPE_BOOL = 1

Variable is of type bool.

Variant.Type TYPE_INT = 2

Variable is of type int.

Variant.Type TYPE_FLOAT = 3

Variable is of type float.

Variant.Type TYPE_STRING = 4

Variable is of type String.

Variant.Type TYPE_VECTOR2 = 5

Variable is of type Vector2.

Variant.Type TYPE_VECTOR2I = 6

Variable is of type Vector2i.

Variant.Type TYPE_RECT2 = 7

Variable is of type Rect2.

Variant.Type TYPE_RECT2I = 8

Variable is of type Rect2i.

Variant.Type TYPE_VECTOR3 = 9

Variable is of type Vector3.

Variant.Type TYPE_VECTOR3I = 10

Variable is of type Vector3i.

Variant.Type TYPE_TRANSFORM2D = 11

Variable is of type Transform2D.

Variant.Type TYPE_VECTOR4 = 12

Variable is of type Vector4.

Variant.Type TYPE_VECTOR4I = 13

Variable is of type Vector4i.

Variant.Type TYPE_PLANE = 14

Variable is of type Plane.

Variant.Type TYPE_QUATERNION = 15

Variable is of type Quaternion.

Variant.Type TYPE_AABB = 16

Variable is of type AABB.

Variant.Type TYPE_BASIS = 17

Variable is of type Basis.

Variant.Type TYPE_TRANSFORM3D = 18

Variable is of type Transform3D.

Variant.Type TYPE_PROJECTION = 19

Variable is of type Projection.

Variant.Type TYPE_COLOR = 20

Variable is of type Color.

Variant.Type TYPE_STRING_NAME = 21

Variable is of type StringName.

Variant.Type TYPE_NODE_PATH = 22

Variable is of type NodePath.

Variant.Type TYPE_RID = 23

Variable is of type RID.

Variant.Type TYPE_OBJECT = 24

Variable is of type Object.

Variant.Type TYPE_CALLABLE = 25

Variable is of type Callable.

Variant.Type TYPE_SIGNAL = 26

Variable is of type Signal.

Variant.Type TYPE_DICTIONARY = 27

Variable is of type Dictionary.

Variant.Type TYPE_ARRAY = 28

Variable is of type Array.

Variant.Type TYPE_PACKED_BYTE_ARRAY = 29

Variable is of type PackedByteArray.

Variant.Type TYPE_PACKED_INT32_ARRAY = 30

Variable is of type PackedInt32Array.

Variant.Type TYPE_PACKED_INT64_ARRAY = 31

Variable is of type PackedInt64Array.

Variant.Type TYPE_PACKED_FLOAT32_ARRAY = 32

Variable is of type PackedFloat32Array.

Variant.Type TYPE_PACKED_FLOAT64_ARRAY = 33

Variable is of type PackedFloat64Array.

Variant.Type TYPE_PACKED_STRING_ARRAY = 34

Variable is of type PackedStringArray.

Variant.Type TYPE_PACKED_VECTOR2_ARRAY = 35

Variable is of type PackedVector2Array.

Variant.Type TYPE_PACKED_VECTOR3_ARRAY = 36

Variable is of type PackedVector3Array.

Variant.Type TYPE_PACKED_COLOR_ARRAY = 37

Variable is of type PackedColorArray.

Variant.Type TYPE_MAX = 38

Represents the size of the Variant.Type enum.


enum Variant.Operator:

Variant.Operator OP_EQUAL = 0

Equality operator (==).

Variant.Operator OP_NOT_EQUAL = 1

Inequality operator (!=).

Variant.Operator OP_LESS = 2

Less than operator (<).

Variant.Operator OP_LESS_EQUAL = 3

Less than or equal operator (<=).

Variant.Operator OP_GREATER = 4

Greater than operator (>).

Variant.Operator OP_GREATER_EQUAL = 5

Greater than or equal operator (>=).

Variant.Operator OP_ADD = 6

Addition operator (+).

Variant.Operator OP_SUBTRACT = 7

Subtraction operator (-).

Variant.Operator OP_MULTIPLY = 8

Multiplication operator (*).

Variant.Operator OP_DIVIDE = 9

Division operator (/).

Variant.Operator OP_NEGATE = 10

Unary negation operator (-).

Variant.Operator OP_POSITIVE = 11

Unary plus operator (+).

Variant.Operator OP_MODULE = 12

Remainder/modulo operator (%).

Variant.Operator OP_POWER = 13

Power operator (**).

Variant.Operator OP_SHIFT_LEFT = 14

Left shift operator (<<).

Variant.Operator OP_SHIFT_RIGHT = 15

Right shift operator (>>).

Variant.Operator OP_BIT_AND = 16

Bitwise AND operator (&).

Variant.Operator OP_BIT_OR = 17

Bitwise OR operator (|).

Variant.Operator OP_BIT_XOR = 18

Bitwise XOR operator (^).

Variant.Operator OP_BIT_NEGATE = 19

Bitwise NOT operator (~).

Variant.Operator OP_AND = 20

Logical AND operator (and or &&).

Variant.Operator OP_OR = 21

Logical OR operator (or or ||).

Variant.Operator OP_XOR = 22

Logical XOR operator (not implemented in GDScript).

Variant.Operator OP_NOT = 23

Logical NOT operator (not or !).

Variant.Operator OP_IN = 24

Logical IN operator (in).

Variant.Operator OP_MAX = 25

Represents the size of the Variant.Operator enum.


Property Descriptions

AudioServer AudioServer

The AudioServer singleton.


CameraServer CameraServer

The CameraServer singleton.


ClassDB ClassDB

The ClassDB singleton.


DisplayServer DisplayServer

The DisplayServer singleton.


Engine Engine

The Engine singleton.


EngineDebugger EngineDebugger

The EngineDebugger singleton.


GDExtensionManager GDExtensionManager

The GDExtensionManager singleton.


Geometry2D Geometry2D

The Geometry2D singleton.


Geometry3D Geometry3D

The Geometry3D singleton.


GodotSharp GodotSharp

The GodotSharp singleton.


IP IP

The IP singleton.


Input Input

The Input singleton.


InputMap InputMap

The InputMap singleton.


JavaClassWrapper JavaClassWrapper

The JavaClassWrapper singleton.

Note: Only implemented on Android.


JavaScriptBridge JavaScriptBridge

The JavaScriptBridge singleton.

Note: Only implemented on the Web platform.


Marshalls Marshalls

The Marshalls singleton.


NavigationMeshGenerator NavigationMeshGenerator

The NavigationMeshGenerator singleton.


NavigationServer2D NavigationServer2D

The NavigationServer2D singleton.


NavigationServer3D NavigationServer3D

The NavigationServer3D singleton.


OS OS

The OS singleton.


Performance Performance

The Performance singleton.


PhysicsServer2D PhysicsServer2D

The PhysicsServer2D singleton.


PhysicsServer2DManager PhysicsServer2DManager

The PhysicsServer2DManager singleton.


PhysicsServer3D PhysicsServer3D

The PhysicsServer3D singleton.


PhysicsServer3DManager PhysicsServer3DManager

The PhysicsServer3DManager singleton.


ProjectSettings ProjectSettings

The ProjectSettings singleton.


RenderingServer RenderingServer

The RenderingServer singleton.


ResourceLoader ResourceLoader

The ResourceLoader singleton.


ResourceSaver ResourceSaver

The ResourceSaver singleton.


ResourceUID ResourceUID

The ResourceUID singleton.


TextServerManager TextServerManager

The TextServerManager singleton.


ThemeDB ThemeDB

The ThemeDB singleton.


Time Time

The Time singleton.


TranslationServer TranslationServer

The TranslationServer singleton.


WorkerThreadPool WorkerThreadPool

The WorkerThreadPool singleton.


XRServer XRServer

The XRServer singleton.


Method Descriptions

Variant abs ( Variant x )

Returns the absolute value of a Variant parameter x (i.e. non-negative value). Supported types: int, float, Vector2, Vector2i, Vector3, Vector3i, Vector4, Vector4i.

  1. var a = abs(-1)
  2. # a is 1
  3. var b = abs(-1.2)
  4. # b is 1.2
  5. var c = abs(Vector2(-3.5, -4))
  6. # c is (3.5, 4)
  7. var d = abs(Vector2i(-5, -6))
  8. # d is (5, 6)
  9. var e = abs(Vector3(-7, 8.5, -3.8))
  10. # e is (7, 8.5, 3.8)
  11. var f = abs(Vector3i(-7, -8, -9))
  12. # f is (7, 8, 9)

Note: For better type safety, use absf, absi, Vector2.abs, Vector2i.abs, Vector3.abs, Vector3i.abs, Vector4.abs, or Vector4i.abs.


float absf ( float x )

Returns the absolute value of float parameter x (i.e. positive value).

  1. # a is 1.2
  2. var a = absf(-1.2)

int absi ( int x )

Returns the absolute value of int parameter x (i.e. positive value).

  1. # a is 1
  2. var a = absi(-1)

float acos ( float x )

Returns the arc cosine of x in radians. Use to get the angle of cosine x. x will be clamped between -1.0 and 1.0 (inclusive), in order to prevent acos from returning @GDScript.NAN.

  1. # c is 0.523599 or 30 degrees if converted with rad_to_deg(c)
  2. var c = acos(0.866025)

float asin ( float x )

Returns the arc sine of x in radians. Use to get the angle of sine x. x will be clamped between -1.0 and 1.0 (inclusive), in order to prevent asin from returning @GDScript.NAN.

  1. # s is 0.523599 or 30 degrees if converted with rad_to_deg(s)
  2. var s = asin(0.5)

float atan ( float x )

Returns the arc tangent of x in radians. Use it to get the angle from an angle’s tangent in trigonometry.

The method cannot know in which quadrant the angle should fall. See atan2 if you have both y and x.

  1. var a = atan(0.5) # a is 0.463648

If x is between -PI / 2 and PI / 2 (inclusive), atan(tan(x)) is equal to x.


float atan2 ( float y, float x )

Returns the arc tangent of y/x in radians. Use to get the angle of tangent y/x. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant.

Important note: The Y coordinate comes first, by convention.

  1. var a = atan2(0, -1) # a is 3.141593

float bezier_derivative ( float start, float control_1, float control_2, float end, float t )

Returns the derivative at the given t on a one-dimensional Bézier curve defined by the given control_1, control_2, and end points.


float bezier_interpolate ( float start, float control_1, float control_2, float end, float t )

Returns the point at the given t on a one-dimensional Bézier curve defined by the given control_1, control_2, and end points.


Variant bytes_to_var ( PackedByteArray bytes )

Decodes a byte array back to a Variant value, without decoding objects.

Note: If you need object deserialization, see bytes_to_var_with_objects.


Variant bytes_to_var_with_objects ( PackedByteArray bytes )

Decodes a byte array back to a Variant value. Decoding objects is allowed.

Warning: Deserialized object can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats (remote code execution).


Variant ceil ( Variant x )

Rounds x upward (towards positive infinity), returning the smallest whole number that is not less than x. Supported types: int, float, Vector2, Vector3, Vector4.

  1. var i = ceil(1.45) # i is 2.0
  2. i = ceil(1.001) # i is 2.0

See also floor, round, and snapped.

Note: For better type safety, use ceilf, ceili, Vector2.ceil, Vector3.ceil, or Vector4.ceil.


float ceilf ( float x )

Rounds x upward (towards positive infinity), returning the smallest whole number that is not less than x.

A type-safe version of ceil, returning a float.


int ceili ( float x )

Rounds x upward (towards positive infinity), returning the smallest whole number that is not less than x.

A type-safe version of ceil, returning an int.


Variant clamp ( Variant value, Variant min, Variant max )

Clamps the value, returning a Variant not less than min and not more than max. Any values that can be compared with the less than and greater than operators will work.

  1. var a = clamp(-10, -1, 5)
  2. # a is -1
  3. var b = clamp(8.1, 0.9, 5.5)
  4. # b is 5.5
  5. var c = clamp(Vector2(-3.5, -4), Vector2(-3.2, -2), Vector2(2, 6.5))
  6. # c is (-3.2, -2)
  7. var d = clamp(Vector2i(7, 8), Vector2i(-3, -2), Vector2i(2, 6))
  8. # d is (2, 6)
  9. var e = clamp(Vector3(-7, 8.5, -3.8), Vector3(-3, -2, 5.4), Vector3(-2, 6, -4.1))
  10. # e is (-3, -2, 5.4)
  11. var f = clamp(Vector3i(-7, -8, -9), Vector3i(-1, 2, 3), Vector3i(-4, -5, -6))
  12. # f is (-4, -5, -6)

Note: For better type safety, use clampf, clampi, Vector2.clamp, Vector2i.clamp, Vector3.clamp, Vector3i.clamp, Vector4.clamp, Vector4i.clamp, or Color.clamp.


float clampf ( float value, float min, float max )

Clamps the value, returning a float not less than min and not more than max.

  1. var speed = 42.1
  2. var a = clampf(speed, 1.0, 20.5) # a is 20.5
  3. speed = -10.0
  4. var b = clampf(speed, -1.0, 1.0) # b is -1.0

int clampi ( int value, int min, int max )

Clamps the value, returning an int not less than min and not more than max.

  1. var speed = 42
  2. var a = clampi(speed, 1, 20) # a is 20
  3. speed = -10
  4. var b = clampi(speed, -1, 1) # b is -1

float cos ( float angle_rad )

Returns the cosine of angle angle_rad in radians.

  1. cos(PI * 2) # Returns 1.0
  2. cos(PI) # Returns -1.0
  3. cos(deg_to_rad(90)) # Returns 0.0

float cosh ( float x )

Returns the hyperbolic cosine of x in radians.

  1. print(cosh(1)) # Prints 1.543081

float cubic_interpolate ( float from, float to, float pre, float post, float weight )

Cubic interpolates between two values by the factor defined in weight with pre and post values.


float cubic_interpolate_angle ( float from, float to, float pre, float post, float weight )

Cubic interpolates between two rotation values with shortest path by the factor defined in weight with pre and post values. See also lerp_angle.


float cubic_interpolate_angle_in_time ( float from, float to, float pre, float post, float weight, float to_t, float pre_t, float post_t )

Cubic interpolates between two rotation values with shortest path by the factor defined in weight with pre and post values. See also lerp_angle.

It can perform smoother interpolation than cubic_interpolate() by the time values.


float cubic_interpolate_in_time ( float from, float to, float pre, float post, float weight, float to_t, float pre_t, float post_t )

Cubic interpolates between two values by the factor defined in weight with pre and post values.

It can perform smoother interpolation than cubic_interpolate by the time values.


float db_to_linear ( float db )

Converts from decibels to linear energy (audio).


float deg_to_rad ( float deg )

Converts an angle expressed in degrees to radians.

  1. var r = deg_to_rad(180) # r is 3.141593

float ease ( float x, float curve )

Returns an “eased” value of x based on an easing function defined with curve. This easing function is based on an exponent. The curve can be any floating-point number, with specific values leading to the following behaviors:

  1. - Lower than -1.0 (exclusive): Ease in-out
  2. - 1.0: Linear
  3. - Between -1.0 and 0.0 (exclusive): Ease out-in
  4. - 0.0: Constant
  5. - Between 0.0 to 1.0 (exclusive): Ease out
  6. - 1.0: Linear
  7. - Greater than 1.0 (exclusive): Ease in

ease() curve values cheatsheet

See also smoothstep. If you need to perform more advanced transitions, use Tween.interpolate_value.


String error_string ( int error )

Returns a human-readable name for the given Error code.

  1. print(OK) # Prints 0
  2. print(error_string(OK)) # Prints OK
  3. print(error_string(ERR_BUSY)) # Prints Busy
  4. print(error_string(ERR_OUT_OF_MEMORY)) # Prints Out of memory

float exp ( float x )

The natural exponential function. It raises the mathematical constant e to the power of x and returns it.

e has an approximate value of 2.71828, and can be obtained with exp(1).

For exponents to other bases use the method pow.

  1. var a = exp(2) # Approximately 7.39

Variant floor ( Variant x )

Rounds x downward (towards negative infinity), returning the largest whole number that is not more than x. Supported types: int, float, Vector2, Vector3, Vector4.

  1. var a = floor(2.99) # a is 2.0
  2. a = floor(-2.99) # a is -3.0

See also ceil, round, and snapped.

Note: For better type safety, use floorf, floori, Vector2.floor, Vector3.floor, or Vector4.floor.


float floorf ( float x )

Rounds x downward (towards negative infinity), returning the largest whole number that is not more than x.

A type-safe version of floor, returning a float.


int floori ( float x )

Rounds x downward (towards negative infinity), returning the largest whole number that is not more than x.

A type-safe version of floor, returning an int.

Note: This function is not the same as int(x), which rounds towards 0.


float fmod ( float x, float y )

Returns the floating-point remainder of x divided by y, keeping the sign of x.

  1. var remainder = fmod(7, 5.5) # remainder is 1.5

For the integer remainder operation, use the % operator.


float fposmod ( float x, float y )

Returns the floating-point modulus of x divided by y, wrapping equally in positive and negative.

  1. print(" (x) (fmod(x, 1.5)) (fposmod(x, 1.5))")
  2. for i in 7:
  3. var x = i * 0.5 - 1.5
  4. print("%4.1f %4.1f | %4.1f" % [x, fmod(x, 1.5), fposmod(x, 1.5)])

Produces:

  1. (x) (fmod(x, 1.5)) (fposmod(x, 1.5))
  2. -1.5 -0.0 | 0.0
  3. -1.0 -1.0 | 0.5
  4. -0.5 -0.5 | 1.0
  5. 0.0 0.0 | 0.0
  6. 0.5 0.5 | 0.5
  7. 1.0 1.0 | 1.0
  8. 1.5 0.0 | 0.0

int hash ( Variant variable )

Returns the integer hash of the passed variable.

GDScriptC#

  1. print(hash("a")) # Prints 177670
  1. GD.Print(GD.Hash("a")); // Prints 177670

Object instance_from_id ( int instance_id )

Returns the Object that corresponds to instance_id. All Objects have a unique instance ID. See also Object.get_instance_id.

GDScriptC#

  1. var foo = "bar"
  2. func _ready():
  3. var id = get_instance_id()
  4. var inst = instance_from_id(id)
  5. print(inst.foo) # Prints bar
  1. public partial class MyNode : Node
  2. {
  3. public string Foo { get; set; } = "bar";
  4. public override void _Ready()
  5. {
  6. ulong id = GetInstanceId();
  7. var inst = (MyNode)InstanceFromId(Id);
  8. GD.Print(inst.Foo); // Prints bar
  9. }
  10. }

float inverse_lerp ( float from, float to, float weight )

Returns an interpolation or extrapolation factor considering the range specified in from and to, and the interpolated value specified in weight. The returned value will be between 0.0 and 1.0 if weight is between from and to (inclusive). If weight is located outside this range, then an extrapolation factor will be returned (return value lower than 0.0 or greater than 1.0). Use clamp on the result of inverse_lerp if this is not desired.

  1. # The interpolation ratio in the `lerp()` call below is 0.75.
  2. var middle = lerp(20, 30, 0.75)
  3. # middle is now 27.5.
  4. # Now, we pretend to have forgotten the original ratio and want to get it back.
  5. var ratio = inverse_lerp(20, 30, 27.5)
  6. # ratio is now 0.75.

See also lerp, which performs the reverse of this operation, and remap to map a continuous series of values to another.


bool is_equal_approx ( float a, float b )

Returns true if a and b are approximately equal to each other.

Here, “approximately equal” means that a and b are within a small internal epsilon of each other, which scales with the magnitude of the numbers.

Infinity values of the same sign are considered equal.


bool is_finite ( float x )

Returns whether x is a finite value, i.e. it is not @GDScript.NAN, positive infinity, or negative infinity.


bool is_inf ( float x )

Returns true if x is either positive infinity or negative infinity.


bool is_instance_id_valid ( int id )

Returns true if the Object that corresponds to id is a valid object (e.g. has not been deleted from memory). All Objects have a unique instance ID.


bool is_instance_valid ( Variant instance )

Returns true if instance is a valid Object (e.g. has not been deleted from memory).


bool is_nan ( float x )

Returns true if x is a NaN (“Not a Number” or invalid) value.


bool is_same ( Variant a, Variant b )

Returns true, for value types, if a and b share the same value. Returns true, for reference types, if the references of a and b are the same.

  1. # Vector2 is a value type
  2. var vec2_a = Vector2(0, 0)
  3. var vec2_b = Vector2(0, 0)
  4. var vec2_c = Vector2(1, 1)
  5. is_same(vec2_a, vec2_a) # true
  6. is_same(vec2_a, vec2_b) # true
  7. is_same(vec2_a, vec2_c) # false
  8. # Array is a reference type
  9. var arr_a = []
  10. var arr_b = []
  11. is_same(arr_a, arr_a) # true
  12. is_same(arr_a, arr_b) # false

These are Variant value types: null, bool, int, float, String, StringName, Vector2, Vector2i, Vector3, Vector3i, Vector4, Vector4i, Rect2, Rect2i, Transform2D, Transform3D, Plane, Quaternion, AABB, Basis, Projection, Color, NodePath, RID, Callable and Signal.

These are Variant reference types: Object, Dictionary, Array, PackedByteArray, PackedInt32Array, PackedInt64Array, PackedFloat32Array, PackedFloat64Array, PackedStringArray, PackedVector2Array, PackedVector3Array and PackedColorArray.


bool is_zero_approx ( float x )

Returns true if x is zero or almost zero. The comparison is done using a tolerance calculation with a small internal epsilon.

This function is faster than using is_equal_approx with one value as zero.


Variant lerp ( Variant from, Variant to, Variant weight )

Linearly interpolates between two values by the factor defined in weight. To perform interpolation, weight should be between 0.0 and 1.0 (inclusive). However, values outside this range are allowed and can be used to perform extrapolation. If this is not desired, use clamp on the result of this function.

Both from and to must be the same type. Supported types: int, float, Vector2, Vector3, Vector4, Color, Quaternion, Basis.

  1. lerp(0, 4, 0.75) # Returns 3.0

See also inverse_lerp which performs the reverse of this operation. To perform eased interpolation with lerp, combine it with ease or smoothstep. See also remap to map a continuous series of values to another.

Note: For better type safety, use lerpf, Vector2.lerp, Vector3.lerp, Vector4.lerp, Color.lerp, Quaternion.slerp or Basis.slerp.


float lerp_angle ( float from, float to, float weight )

Linearly interpolates between two angles (in radians) by a weight value between 0.0 and 1.0.

Similar to lerp, but interpolates correctly when the angles wrap around @GDScript.TAU. To perform eased interpolation with lerp_angle, combine it with ease or smoothstep.

  1. extends Sprite
  2. var elapsed = 0.0
  3. func _process(delta):
  4. var min_angle = deg_to_rad(0.0)
  5. var max_angle = deg_to_rad(90.0)
  6. rotation = lerp_angle(min_angle, max_angle, elapsed)
  7. elapsed += delta

Note: This function lerps through the shortest path between from and to. However, when these two angles are approximately PI + k * TAU apart for any integer k, it’s not obvious which way they lerp due to floating-point precision errors. For example, lerp_angle(0, PI, weight) lerps counter-clockwise, while lerp_angle(0, PI + 5 * TAU, weight) lerps clockwise.


float lerpf ( float from, float to, float weight )

Linearly interpolates between two values by the factor defined in weight. To perform interpolation, weight should be between 0.0 and 1.0 (inclusive). However, values outside this range are allowed and can be used to perform extrapolation. If this is not desired, use clampf on the result of this function.

  1. lerpf(0, 4, 0.75) # Returns 3.0

See also inverse_lerp which performs the reverse of this operation. To perform eased interpolation with lerp, combine it with ease or smoothstep.


float linear_to_db ( float lin )

Converts from linear energy to decibels (audio). This can be used to implement volume sliders that behave as expected (since volume isn’t linear).

Example:

  1. # "Slider" refers to a node that inherits Range such as HSlider or VSlider.
  2. # Its range must be configured to go from 0 to 1.
  3. # Change the bus name if you'd like to change the volume of a specific bus only.
  4. AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), linear_to_db($Slider.value))

float log ( float x )

Returns the natural logarithm of x (base [i]e[/i]), with e being approximately 2.71828). This is the amount of time needed to reach a certain level of continuous growth.

Note: This is not the same as the “log” function on most calculators, which uses a base 10 logarithm. To use base 10 logarithm, use log(x) / log(10).

  1. log(10) # Returns 2.302585

Note: The logarithm of 0 returns -inf, while negative values return -nan.


Variant max () vararg

Returns the maximum of the given numeric values. This function can take any number of arguments.

  1. max(1, 7, 3, -6, 5) # Returns 7

float maxf ( float a, float b )

Returns the maximum of two float values.

  1. maxf(3.6, 24) # Returns 24.0
  2. maxf(-3.99, -4) # Returns -3.99

int maxi ( int a, int b )

Returns the maximum of two int values.

  1. maxi(1, 2) # Returns 2
  2. maxi(-3, -4) # Returns -3

Variant min () vararg

Returns the minimum of the given numeric values. This function can take any number of arguments.

  1. min(1, 7, 3, -6, 5) # Returns -6

float minf ( float a, float b )

Returns the minimum of two float values.

  1. minf(3.6, 24) # Returns 3.6
  2. minf(-3.99, -4) # Returns -4.0

int mini ( int a, int b )

Returns the minimum of two int values.

  1. mini(1, 2) # Returns 1
  2. mini(-3, -4) # Returns -4

float move_toward ( float from, float to, float delta )

Moves from toward to by the delta amount. Will not go past to.

Use a negative delta value to move away.

  1. move_toward(5, 10, 4) # Returns 9
  2. move_toward(10, 5, 4) # Returns 6
  3. move_toward(5, 10, 9) # Returns 10
  4. move_toward(10, 5, -1.5) # Returns 11.5

int nearest_po2 ( int value )

Returns the nearest equal or larger power of 2 for the integer value.

In other words, returns the smallest value a where a = pow(2, n) such that value <= a for some non-negative integer n.

  1. nearest_po2(3) # Returns 4
  2. nearest_po2(4) # Returns 4
  3. nearest_po2(5) # Returns 8
  4. nearest_po2(0) # Returns 0 (this may not be expected)
  5. nearest_po2(-1) # Returns 0 (this may not be expected)

Warning: Due to the way it is implemented, this function returns 0 rather than 1 for negative values of value (in reality, 1 is the smallest integer power of 2).


float pingpong ( float value, float length )

Wraps value between 0 and the length. If the limit is reached, the next value the function returns is decreased to the 0 side or increased to the length side (like a triangle wave). If length is less than zero, it becomes positive.

  1. pingpong(-3.0, 3.0) # Returns 3.0
  2. pingpong(-2.0, 3.0) # Returns 2.0
  3. pingpong(-1.0, 3.0) # Returns 1.0
  4. pingpong(0.0, 3.0) # Returns 0.0
  5. pingpong(1.0, 3.0) # Returns 1.0
  6. pingpong(2.0, 3.0) # Returns 2.0
  7. pingpong(3.0, 3.0) # Returns 3.0
  8. pingpong(4.0, 3.0) # Returns 2.0
  9. pingpong(5.0, 3.0) # Returns 1.0
  10. pingpong(6.0, 3.0) # Returns 0.0

int posmod ( int x, int y )

Returns the integer modulus of x divided by y that wraps equally in positive and negative.

  1. print("#(i) (i % 3) (posmod(i, 3))")
  2. for i in range(-3, 4):
  3. print("%2d %2d | %2d" % [i, i % 3, posmod(i, 3)])

Produces:

  1. (i) (i % 3) (posmod(i, 3))
  2. -3 0 | 0
  3. -2 -2 | 1
  4. -1 -1 | 2
  5. 0 0 | 0
  6. 1 1 | 1
  7. 2 2 | 2
  8. 3 0 | 0

float pow ( float base, float exp )

Returns the result of base raised to the power of exp.

In GDScript, this is the equivalent of the ** operator.

  1. pow(2, 5) # Returns 32.0
  2. pow(4, 1.5) # Returns 8.0

void print () vararg

Converts one or more arguments of any type to string in the best way possible and prints them to the console.

GDScriptC#

  1. var a = [1, 2, 3]
  2. print("a", "b", a) # Prints ab[1, 2, 3]
  1. var a = new Godot.Collections.Array { 1, 2, 3 };
  2. GD.Print("a", "b", a); // Prints ab[1, 2, 3]

Note: Consider using push_error and push_warning to print error and warning messages instead of print or print_rich. This distinguishes them from print messages used for debugging purposes, while also displaying a stack trace when an error or warning is printed.


void print_rich () vararg

Converts one or more arguments of any type to string in the best way possible and prints them to the console.

The following BBCode tags are supported: b, i, u, s, indent, code, url, center, right, color, bgcolor, fgcolor.

Color tags only support the following named colors: black, red, green, yellow, blue, magenta, pink, purple, cyan, white, orange, gray. Hexadecimal color codes are not supported.

URL tags only support URLs wrapped by a URL tag, not URLs with a different title.

When printing to standard output, the supported subset of BBCode is converted to ANSI escape codes for the terminal emulator to display. Support for ANSI escape codes varies across terminal emulators, especially for italic and strikethrough. In standard output, code is represented with faint text but without any font change. Unsupported tags are left as-is in standard output.

GDScriptC#

  1. print_rich("[color=green][b]Hello world![/b][/color]") # Prints out "Hello world!" in green with a bold font
  1. GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints out "Hello world!" in green with a bold font

Note: Consider using push_error and push_warning to print error and warning messages instead of print or print_rich. This distinguishes them from print messages used for debugging purposes, while also displaying a stack trace when an error or warning is printed.

Note: On Windows, only Windows 10 and later correctly displays ANSI escape codes in standard output.


void print_verbose () vararg

If verbose mode is enabled (OS.is_stdout_verbose returning true), converts one or more arguments of any type to string in the best way possible and prints them to the console.


void printerr () vararg

Prints one or more arguments to strings in the best way possible to standard error line.

GDScriptC#

  1. printerr("prints to stderr")
  1. GD.PrintErr("prints to stderr");

void printraw () vararg

Prints one or more arguments to strings in the best way possible to the OS terminal. Unlike print, no newline is automatically added at the end.

GDScriptC#

  1. printraw("A")
  2. printraw("B")
  3. printraw("C")
  4. # Prints ABC to terminal
  1. GD.PrintRaw("A");
  2. GD.PrintRaw("B");
  3. GD.PrintRaw("C");
  4. // Prints ABC to terminal

void prints () vararg

Prints one or more arguments to the console with a space between each argument.

GDScriptC#

  1. prints("A", "B", "C") # Prints A B C
  1. GD.PrintS("A", "B", "C"); // Prints A B C

void printt () vararg

Prints one or more arguments to the console with a tab between each argument.

GDScriptC#

  1. printt("A", "B", "C") # Prints A B C
  1. GD.PrintT("A", "B", "C"); // Prints A B C

void push_error () vararg

Pushes an error message to Godot’s built-in debugger and to the OS terminal.

GDScriptC#

  1. push_error("test error") # Prints "test error" to debugger and terminal as error call
  1. GD.PushError("test error"); // Prints "test error" to debugger and terminal as error call

Note: This function does not pause project execution. To print an error message and pause project execution in debug builds, use assert(false, "test error") instead.


void push_warning () vararg

Pushes a warning message to Godot’s built-in debugger and to the OS terminal.

GDScriptC#

  1. push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call
  1. GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as warning call

float rad_to_deg ( float rad )

Converts an angle expressed in radians to degrees.

  1. rad_to_deg(0.523599) # Returns 30
  2. rad_to_deg(PI) # Returns 180
  3. rad_to_deg(PI * 2) # Returns 360

PackedInt64Array rand_from_seed ( int seed )

Given a seed, returns a PackedInt64Array of size 2, where its first element is the randomized int value, and the second element is the same as seed. Passing the same seed consistently returns the same array.

Note: “Seed” here refers to the internal state of the pseudo random number generator, currently implemented as a 64 bit integer.

  1. var a = rand_from_seed(4)
  2. print(a[0]) # Prints 2879024997
  3. print(a[1]) # Prints 4

float randf ( )

Returns a random floating point value between 0.0 and 1.0 (inclusive).

GDScriptC#

  1. randf() # Returns e.g. 0.375671
  1. GD.Randf(); // Returns e.g. 0.375671

float randf_range ( float from, float to )

Returns a random floating point value between from and to (inclusive).

GDScriptC#

  1. randf_range(0, 20.5) # Returns e.g. 7.45315
  2. randf_range(-10, 10) # Returns e.g. -3.844535
  1. GD.RandRange(0.0, 20.5); // Returns e.g. 7.45315
  2. GD.RandRange(-10.0, 10.0); // Returns e.g. -3.844535

float randfn ( float mean, float deviation )

Returns a normally-distributed pseudo-random floating point value using Box-Muller transform with the specified mean and a standard deviation. This is also called Gaussian distribution.


int randi ( )

Returns a random unsigned 32-bit integer. Use remainder to obtain a random value in the interval [0, N - 1] (where N is smaller than 2^32).

GDScriptC#

  1. randi() # Returns random integer between 0 and 2^32 - 1
  2. randi() % 20 # Returns random integer between 0 and 19
  3. randi() % 100 # Returns random integer between 0 and 99
  4. randi() % 100 + 1 # Returns random integer between 1 and 100
  1. GD.Randi(); // Returns random integer between 0 and 2^32 - 1
  2. GD.Randi() % 20; // Returns random integer between 0 and 19
  3. GD.Randi() % 100; // Returns random integer between 0 and 99
  4. GD.Randi() % 100 + 1; // Returns random integer between 1 and 100

int randi_range ( int from, int to )

Returns a random signed 32-bit integer between from and to (inclusive). If to is lesser than from, they are swapped.

GDScriptC#

  1. randi_range(0, 1) # Returns either 0 or 1
  2. randi_range(-10, 1000) # Returns random integer between -10 and 1000
  1. GD.RandRange(0, 1); // Returns either 0 or 1
  2. GD.RandRange(-10, 1000); // Returns random integer between -10 and 1000

void randomize ( )

Randomizes the seed (or the internal state) of the random number generator. The current implementation uses a number based on the device’s time.

Note: This function is called automatically when the project is run. If you need to fix the seed to have consistent, reproducible results, use seed to initialize the random number generator.


float remap ( float value, float istart, float istop, float ostart, float ostop )

Maps a value from range [istart, istop] to [ostart, ostop]. See also lerp and inverse_lerp. If value is outside [istart, istop], then the resulting value will also be outside [ostart, ostop]. If this is not desired, use clamp on the result of this function.

  1. remap(75, 0, 100, -1, 1) # Returns 0.5

For complex use cases where multiple ranges are needed, consider using Curve or Gradient instead.


int rid_allocate_id ( )

Allocates a unique ID which can be used by the implementation to construct a RID. This is used mainly from native extensions to implement servers.


RID rid_from_int64 ( int base )

Creates a RID from a base. This is used mainly from native extensions to build servers.


Variant round ( Variant x )

Rounds x to the nearest whole number, with halfway cases rounded away from 0. Supported types: int, float, Vector2, Vector3, Vector4.

  1. round(2.4) # Returns 2
  2. round(2.5) # Returns 3
  3. round(2.6) # Returns 3

See also floor, ceil, and snapped.

Note: For better type safety, use roundf, roundi, Vector2.round, Vector3.round, or Vector4.round.


float roundf ( float x )

Rounds x to the nearest whole number, with halfway cases rounded away from 0.

A type-safe version of round, returning a float.


int roundi ( float x )

Rounds x to the nearest whole number, with halfway cases rounded away from 0.

A type-safe version of round, returning an int.


void seed ( int base )

Sets the seed for the random number generator to base. Setting the seed manually can ensure consistent, repeatable results for most random functions.

GDScriptC#

  1. var my_seed = "Godot Rocks".hash()
  2. seed(my_seed)
  3. var a = randf() + randi()
  4. seed(my_seed)
  5. var b = randf() + randi()
  6. # a and b are now identical
  1. ulong mySeed = (ulong)GD.Hash("Godot Rocks");
  2. GD.Seed(mySeed);
  3. var a = GD.Randf() + GD.Randi();
  4. GD.Seed(mySeed);
  5. var b = GD.Randf() + GD.Randi();
  6. // a and b are now identical

Variant sign ( Variant x )

Returns the same type of Variant as x, with -1 for negative values, 1 for positive values, and 0 for zeros. Supported types: int, float, Vector2, Vector2i, Vector3, Vector3i, Vector4, Vector4i.

  1. sign(-6.0) # Returns -1
  2. sign(0.0) # Returns 0
  3. sign(6.0) # Returns 1
  4. sign(Vector3(-6.0, 0.0, 6.0)) # Returns (-1, 0, 1)

Note: For better type safety, use signf, signi, Vector2.sign, Vector2i.sign, Vector3.sign, Vector3i.sign, Vector4.sign, or Vector4i.sign.


float signf ( float x )

Returns -1.0 if x is negative, 1.0 if x is positive, and 0.0 if x is zero.

  1. signf(-6.5) # Returns -1.0
  2. signf(0.0) # Returns 0.0
  3. signf(6.5) # Returns 1.0

int signi ( int x )

Returns -1 if x is negative, 1 if x is positive, and 0 if if x is zero.

  1. signi(-6) # Returns -1
  2. signi(0) # Returns 0
  3. signi(6) # Returns 1

float sin ( float angle_rad )

Returns the sine of angle angle_rad in radians.

  1. sin(0.523599) # Returns 0.5
  2. sin(deg_to_rad(90)) # Returns 1.0

float sinh ( float x )

Returns the hyperbolic sine of x.

  1. var a = log(2.0) # Returns 0.693147
  2. sinh(a) # Returns 0.75

float smoothstep ( float from, float to, float x )

Returns the result of smoothly interpolating the value of x between 0 and 1, based on the where x lies with respect to the edges from and to.

The return value is 0 if x <= from, and 1 if x >= to. If x lies between from and to, the returned value follows an S-shaped curve that maps x between 0 and 1.

This S-shaped curve is the cubic Hermite interpolator, given by f(y) = 3*y^2 - 2*y^3 where y = (x-from) / (to-from).

  1. smoothstep(0, 2, -5.0) # Returns 0.0
  2. smoothstep(0, 2, 0.5) # Returns 0.15625
  3. smoothstep(0, 2, 1.0) # Returns 0.5
  4. smoothstep(0, 2, 2.0) # Returns 1.0

Compared to ease with a curve value of -1.6521, smoothstep returns the smoothest possible curve with no sudden changes in the derivative. If you need to perform more advanced transitions, use Tween or AnimationPlayer.

Comparison between smoothstep() and ease(x, -1.6521) return values


Variant snapped ( Variant x, Variant step )

Returns the multiple of step that is the closest to x. This can also be used to round a floating point number to an arbitrary number of decimals.

The returned value is the same type of Variant as step. Supported types: int, float, Vector2, Vector2i, Vector3, Vector3i, Vector4, Vector4i.

  1. snapped(100, 32) # Returns 96
  2. snapped(3.14159, 0.01) # Returns 3.14
  3. snapped(Vector2(34, 70), Vector2(8, 8)) # Returns (32, 72)

See also ceil, floor, and round.

Note: For better type safety, use snappedf, snappedi, Vector2.snapped, Vector2i.snapped, Vector3.snapped, Vector3i.snapped, Vector4.snapped, or Vector4i.snapped.


float snappedf ( float x, float step )

Returns the multiple of step that is the closest to x. This can also be used to round a floating point number to an arbitrary number of decimals.

A type-safe version of snapped, returning a float.

  1. snappedf(32.0, 2.5) # Returns 32.5
  2. snappedf(3.14159, 0.01) # Returns 3.14

int snappedi ( float x, int step )

Returns the multiple of step that is the closest to x.

A type-safe version of snapped, returning an int.

  1. snappedi(53, 16) # Returns 48
  2. snappedi(4096, 100) # Returns 4100

float sqrt ( float x )

Returns the square root of x, where x is a non-negative number.

  1. sqrt(9) # Returns 3
  2. sqrt(10.24) # Returns 3.2
  3. sqrt(-1) # Returns NaN

Note: Negative values of x return NaN (“Not a Number”). in C#, if you need negative inputs, use System.Numerics.Complex.


int step_decimals ( float x )

Returns the position of the first non-zero digit, after the decimal point. Note that the maximum return value is 10, which is a design decision in the implementation.

  1. var n = step_decimals(5) # n is 0
  2. n = step_decimals(1.0005) # n is 4
  3. n = step_decimals(0.000000005) # n is 9

String str () vararg

Converts one or more arguments of any Variant type to a String in the best way possible.

  1. var a = [10, 20, 30]
  2. var b = str(a)
  3. print(len(a)) # Prints 3 (the number of elements in the array).
  4. print(len(b)) # Prints 12 (the length of the string "[10, 20, 30]").

Variant str_to_var ( String string )

Converts a formatted string that was returned by var_to_str to the original Variant.

GDScriptC#

  1. var data = '{ "a": 1, "b": 2 }' # data is a String
  2. var dict = str_to_var(data) # dict is a Dictionary
  3. print(dict["a"]) # Prints 1
  1. string data = "{ \"a\": 1, \"b\": 2 }"; // data is a string
  2. var dict = GD.StrToVar(data).AsGodotDictionary(); // dict is a Dictionary
  3. GD.Print(dict["a"]); // Prints 1

float tan ( float angle_rad )

Returns the tangent of angle angle_rad in radians.

  1. tan(deg_to_rad(45)) # Returns 1

float tanh ( float x )

Returns the hyperbolic tangent of x.

  1. var a = log(2.0) # Returns 0.693147
  2. tanh(a) # Returns 0.6

int typeof ( Variant variable )

Returns the internal type of the given variable, using the Variant.Type values.

  1. var json = JSON.new()
  2. json.parse('["a", "b", "c"]')
  3. var result = json.get_data()
  4. if typeof(result) == TYPE_ARRAY:
  5. print(result[0]) # Prints a
  6. else:
  7. print("Unexpected result")

PackedByteArray var_to_bytes ( Variant variable )

Encodes a Variant value to a byte array, without encoding objects. Deserialization can be done with bytes_to_var.

Note: If you need object serialization, see var_to_bytes_with_objects.


PackedByteArray var_to_bytes_with_objects ( Variant variable )

Encodes a Variant value to a byte array. Encoding objects is allowed (and can potentially include executable code). Deserialization can be done with bytes_to_var_with_objects.


String var_to_str ( Variant variable )

Converts a Variant variable to a formatted String that can then be parsed using str_to_var.

GDScriptC#

  1. var a = { "a": 1, "b": 2 }
  2. print(var_to_str(a))
  1. var a = new Godot.Collections.Dictionary { ["a"] = 1, ["b"] = 2 };
  2. GD.Print(GD.VarToStr(a));

Prints:

  1. {
  2. "a": 1,
  3. "b": 2
  4. }

Note: Converting Signal or Callable is not supported and will result in an empty value for these types, regardless of their data.


Variant weakref ( Variant obj )

Returns a weak reference to an object, or null if obj is invalid.

A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. However, until the object is actually destroyed the weak reference may return the object even if there are no strong references to it.


Variant wrap ( Variant value, Variant min, Variant max )

Wraps the Variant value between min and max. Can be used for creating loop-alike behavior or infinite surfaces.

Variant types int and float are supported. If any of the arguments is float this function returns a float, otherwise it returns an int.

  1. var a = wrap(4, 5, 10)
  2. # a is 9 (int)
  3. var a = wrap(7, 5, 10)
  4. # a is 7 (int)
  5. var a = wrap(10.5, 5, 10)
  6. # a is 5.5 (float)

float wrapf ( float value, float min, float max )

Wraps the float value between min and max. Can be used for creating loop-alike behavior or infinite surfaces.

  1. # Infinite loop between 5.0 and 9.9
  2. value = wrapf(value + 0.1, 5.0, 10.0)
  1. # Infinite rotation (in radians)
  2. angle = wrapf(angle + 0.1, 0.0, TAU)
  1. # Infinite rotation (in radians)
  2. angle = wrapf(angle + 0.1, -PI, PI)

Note: If min is 0, this is equivalent to fposmod, so prefer using that instead.

wrapf is more flexible than using the fposmod approach by giving the user control over the minimum value.


int wrapi ( int value, int min, int max )

Wraps the integer value between min and max. Can be used for creating loop-alike behavior or infinite surfaces.

  1. # Infinite loop between 5 and 9
  2. frame = wrapi(frame + 1, 5, 10)
  1. # result is -2
  2. var result = wrapi(-6, -5, -1)