Global scope constants and functions.
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].
$DOCS_URL/tutorials/math/random_number_generation.html
Returns the absolute value of a [Variant] parameter [param x] (i.e. non-negative value). Supported types: [int], [float], [Vector2], [Vector2i], [Vector3], [Vector3i], [Vector4], [Vector4i].
[codeblock]
var a = abs(-1)
# a is 1
var b = abs(-1.2)
# b is 1.2
var c = abs(Vector2(-3.5, -4))
# c is (3.5, 4)
var d = abs(Vector2i(-5, -6))
# d is (5, 6)
var e = abs(Vector3(-7, 8.5, -3.8))
# e is (7, 8.5, 3.8)
var f = abs(Vector3i(-7, -8, -9))
# f is (7, 8, 9)
[/codeblock]
[b]Note:[/b] For better type safety, use [method absf], [method absi], [method Vector2.abs], [method Vector2i.abs], [method Vector3.abs], [method Vector3i.abs], [method Vector4.abs], or [method Vector4i.abs].
Returns the absolute value of float parameter [param x] (i.e. positive value).
[codeblock]
# a is 1.2
var a = absf(-1.2)
[/codeblock]
Returns the absolute value of int parameter [param x] (i.e. positive value).
[codeblock]
# a is 1
var a = absi(-1)
[/codeblock]
Returns the arc cosine of [param x] in radians. Use to get the angle of cosine [param x]. [param x] will be clamped between [code]-1.0[/code] and [code]1.0[/code] (inclusive), in order to prevent [method acos] from returning [constant @GDScript.NAN].
[codeblock]
# c is 0.523599 or 30 degrees if converted with rad_to_deg(c)
var c = acos(0.866025)
[/codeblock]
Returns the arc sine of [param x] in radians. Use to get the angle of sine [param x]. [param x] will be clamped between [code]-1.0[/code] and [code]1.0[/code] (inclusive), in order to prevent [method asin] from returning [constant @GDScript.NAN].
[codeblock]
# s is 0.523599 or 30 degrees if converted with rad_to_deg(s)
var s = asin(0.5)
[/codeblock]
Returns the arc tangent of [param 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 [method atan2] if you have both [code]y[/code] and [code]x[/code].
[codeblock]
var a = atan(0.5) # a is 0.463648
[/codeblock]
If [param x] is between [code]-PI / 2[/code] and [code]PI / 2[/code] (inclusive), [code]atan(tan(x))[/code] is equal to [param x].
Returns the arc tangent of [code]y/x[/code] in radians. Use to get the angle of tangent [code]y/x[/code]. 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.
[codeblock]
var a = atan2(0, -1) # a is 3.141593
[/codeblock]
Returns the derivative at the given [param t] on a one-dimensional [url=https://en.wikipedia.org/wiki/B%C3%A9zier_curve]Bézier curve[/url] defined by the given [param control_1], [param control_2], and [param end] points.
Returns the point at the given [param t] on a one-dimensional [url=https://en.wikipedia.org/wiki/B%C3%A9zier_curve]Bézier curve[/url] defined by the given [param control_1], [param control_2], and [param end] points.
Decodes a byte array back to a [Variant] value, without decoding objects.
[b]Note:[/b] If you need object deserialization, see [method bytes_to_var_with_objects].
Decodes a byte array back to a [Variant] value. Decoding objects is allowed.
[b]Warning:[/b] 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).
Rounds [param x] upward (towards positive infinity), returning the smallest whole number that is not less than [param x]. Supported types: [int], [float], [Vector2], [Vector3], [Vector4].
[codeblock]
var i = ceil(1.45) # i is 2.0
i = ceil(1.001) # i is 2.0
[/codeblock]
See also [method floor], [method round], and [method snapped].
[b]Note:[/b] For better type safety, use [method ceilf], [method ceili], [method Vector2.ceil], [method Vector3.ceil], or [method Vector4.ceil].
Rounds [param x] upward (towards positive infinity), returning the smallest whole number that is not less than [param x].
A type-safe version of [method ceil], returning a [float].
Rounds [param x] upward (towards positive infinity), returning the smallest whole number that is not less than [param x].
A type-safe version of [method ceil], returning an [int].
Clamps the [param value], returning a [Variant] not less than [param min] and not more than [param max]. Supported types: [int], [float], [Vector2], [Vector2i], [Vector3], [Vector3i], [Vector4], [Vector4i].
[codeblock]
var a = clamp(-10, -1, 5)
# a is -1
var b = clamp(8.1, 0.9, 5.5)
# b is 5.5
var c = clamp(Vector2(-3.5, -4), Vector2(-3.2, -2), Vector2(2, 6.5))
# c is (-3.2, -2)
var d = clamp(Vector2i(7, 8), Vector2i(-3, -2), Vector2i(2, 6))
# d is (2, 6)
var e = clamp(Vector3(-7, 8.5, -3.8), Vector3(-3, -2, 5.4), Vector3(-2, 6, -4.1))
# e is (-3, -2, 5.4)
var f = clamp(Vector3i(-7, -8, -9), Vector3i(-1, 2, 3), Vector3i(-4, -5, -6))
# f is (-4, -5, -6)
[/codeblock]
[b]Note:[/b] For better type safety, use [method clampf], [method clampi], [method Vector2.clamp], [method Vector2i.clamp], [method Vector3.clamp], [method Vector3i.clamp], [method Vector4.clamp], or [method Vector4i.clamp].
Clamps the [param value], returning a [float] not less than [param min] and not more than [param max].
[codeblock]
var speed = 42.1
var a = clampf(speed, 1.0, 20.5) # a is 20.5
speed = -10.0
var b = clampf(speed, -1.0, 1.0) # b is -1.0
[/codeblock]
Clamps the [param value], returning an [int] not less than [param min] and not more than [param max].
[codeblock]
var speed = 42
var a = clampi(speed, 1, 20) # a is 20
speed = -10
var b = clampi(speed, -1, 1) # b is -1
[/codeblock]
Returns the cosine of angle [param angle_rad] in radians.
[codeblock]
cos(PI * 2) # Returns 1.0
cos(PI) # Returns -1.0
cos(deg_to_rad(90)) # Returns 0.0
[/codeblock]
Returns the hyperbolic cosine of [param x] in radians.
[codeblock]
print(cosh(1)) # Prints 1.543081
[/codeblock]
Cubic interpolates between two values by the factor defined in [param weight] with [param pre] and [param post] values.
Cubic interpolates between two rotation values with shortest path by the factor defined in [param weight] with [param pre] and [param post] values. See also [method lerp_angle].
Cubic interpolates between two rotation values with shortest path by the factor defined in [param weight] with [param pre] and [param post] values. See also [method lerp_angle].
It can perform smoother interpolation than [code]cubic_interpolate()[/code] by the time values.
Cubic interpolates between two values by the factor defined in [param weight] with [param pre] and [param post] values.
It can perform smoother interpolation than [method cubic_interpolate] by the time values.
Converts from decibels to linear energy (audio).
Converts an angle expressed in degrees to radians.
[codeblock]
var r = deg_to_rad(180) # r is 3.141593
[/codeblock]
Returns an "eased" value of [param x] based on an easing function defined with [param curve]. This easing function is based on an exponent. The [param curve] can be any floating-point number, with specific values leading to the following behaviors:
[codeblock]
- Lower than -1.0 (exclusive): Ease in-out
- 1.0: Linear
- Between -1.0 and 0.0 (exclusive): Ease out-in
- 0.0: Constant
- Between 0.0 to 1.0 (exclusive): Ease out
- 1.0: Linear
- Greater than 1.0 (exclusive): Ease in
[/codeblock]
[url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/ease_cheatsheet.png]ease() curve values cheatsheet[/url]
See also [method smoothstep]. If you need to perform more advanced transitions, use [method Tween.interpolate_value].
Returns a human-readable name for the given [enum Error] code.
[codeblock]
print(OK) # Prints 0
print(error_string(OK)) # Prints OK
print(error_string(ERR_BUSY)) # Prints Busy
print(error_string(ERR_OUT_OF_MEMORY)) # Prints Out of memory
[/codeblock]
The natural exponential function. It raises the mathematical constant [b]e[/b] to the power of [param x] and returns it.
[b]e[/b] has an approximate value of 2.71828, and can be obtained with [code]exp(1)[/code].
For exponents to other bases use the method [method pow].
[codeblock]
var a = exp(2) # Approximately 7.39
[/codeblock]
Rounds [param x] downward (towards negative infinity), returning the largest whole number that is not more than [param x]. Supported types: [int], [float], [Vector2], [Vector3], [Vector4].
[codeblock]
var a = floor(2.99) # a is 2.0
a = floor(-2.99) # a is -3.0
[/codeblock]
See also [method ceil], [method round], and [method snapped].
[b]Note:[/b] For better type safety, use [method floorf], [method floori], [method Vector2.floor], [method Vector3.floor], or [method Vector4.floor].
Rounds [param x] downward (towards negative infinity), returning the largest whole number that is not more than [param x].
A type-safe version of [method floor], returning a [float].
Rounds [param x] downward (towards negative infinity), returning the largest whole number that is not more than [param x].
A type-safe version of [method floor], returning an [int].
[b]Note:[/b] This function is [i]not[/i] the same as [code]int(x)[/code], which rounds towards 0.
Returns the floating-point remainder of [param x] divided by [param y], keeping the sign of [param x].
[codeblock]
var remainder = fmod(7, 5.5) # remainder is 1.5
[/codeblock]
For the integer remainder operation, use the [code]%[/code] operator.
Returns the floating-point modulus of [param x] divided by [param y], wrapping equally in positive and negative.
[codeblock]
print(" (x) (fmod(x, 1.5)) (fposmod(x, 1.5))")
for i in 7:
var x = i * 0.5 - 1.5
print("%4.1f %4.1f | %4.1f" % [x, fmod(x, 1.5), fposmod(x, 1.5)])
[/codeblock]
Produces:
[codeblock]
(x) (fmod(x, 1.5)) (fposmod(x, 1.5))
-1.5 -0.0 | 0.0
-1.0 -1.0 | 0.5
-0.5 -0.5 | 1.0
0.0 0.0 | 0.0
0.5 0.5 | 0.5
1.0 1.0 | 1.0
1.5 0.0 | 0.0
[/codeblock]
Returns the integer hash of the passed [param variable].
[codeblocks]
[gdscript]
print(hash("a")) # Prints 177670
[/gdscript]
[csharp]
GD.Print(GD.Hash("a")); // Prints 177670
[/csharp]
[/codeblocks]
Returns the [Object] that corresponds to [param instance_id]. All Objects have a unique instance ID. See also [method Object.get_instance_id].
[codeblocks]
[gdscript]
var foo = "bar"
func _ready():
var id = get_instance_id()
var inst = instance_from_id(id)
print(inst.foo) # Prints bar
[/gdscript]
[csharp]
public partial class MyNode : Node
{
public string Foo { get; set; } = "bar";
public override void _Ready()
{
ulong id = GetInstanceId();
var inst = (MyNode)InstanceFromId(Id);
GD.Print(inst.Foo); // Prints bar
}
}
[/csharp]
[/codeblocks]
Returns an interpolation or extrapolation factor considering the range specified in [param from] and [param to], and the interpolated value specified in [param weight]. The returned value will be between [code]0.0[/code] and [code]1.0[/code] if [param weight] is between [param from] and [param to] (inclusive). If [param weight] is located outside this range, then an extrapolation factor will be returned (return value lower than [code]0.0[/code] or greater than [code]1.0[/code]). Use [method clamp] on the result of [method inverse_lerp] if this is not desired.
[codeblock]
# The interpolation ratio in the `lerp()` call below is 0.75.
var middle = lerp(20, 30, 0.75)
# middle is now 27.5.
# Now, we pretend to have forgotten the original ratio and want to get it back.
var ratio = inverse_lerp(20, 30, 27.5)
# ratio is now 0.75.
[/codeblock]
See also [method lerp], which performs the reverse of this operation, and [method remap] to map a continuous series of values to another.
Returns [code]true[/code] if [param a] and [param b] are approximately equal to each other.
Here, "approximately equal" means that [param a] and [param 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.
Returns whether [param x] is a finite value, i.e. it is not [constant @GDScript.NAN], positive infinity, or negative infinity.
Returns [code]true[/code] if [param x] is either positive infinity or negative infinity.
Returns [code]true[/code] if the Object that corresponds to [param id] is a valid object (e.g. has not been deleted from memory). All Objects have a unique instance ID.
Returns [code]true[/code] if [param instance] is a valid Object (e.g. has not been deleted from memory).
Returns [code]true[/code] if [param x] is a NaN ("Not a Number" or invalid) value.
Returns [code]true[/code], for value types, if [param a] and [param b] share the same value. Returns [code]true[/code], for reference types, if the references of [param a] and [param b] are the same.
[codeblock]
# Vector2 is a value type
var vec2_a = Vector2(0, 0)
var vec2_b = Vector2(0, 0)
var vec2_c = Vector2(1, 1)
is_same(vec2_a, vec2_a) # true
is_same(vec2_a, vec2_b) # true
is_same(vec2_a, vec2_c) # false
# Array is a reference type
var arr_a = []
var arr_b = []
is_same(arr_a, arr_a) # true
is_same(arr_a, arr_b) # false
[/codeblock]
These are [Variant] value types: [code]null[/code], [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].
Returns [code]true[/code] if [param 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 [method is_equal_approx] with one value as zero.
Linearly interpolates between two values by the factor defined in [param weight]. To perform interpolation, [param weight] should be between [code]0.0[/code] and [code]1.0[/code] (inclusive). However, values outside this range are allowed and can be used to perform [i]extrapolation[/i]. If this is not desired, use [method clamp] on the result of this function.
Both [param from] and [param to] must be the same type. Supported types: [int], [float], [Vector2], [Vector3], [Vector4], [Color], [Quaternion], [Basis].
[codeblock]
lerp(0, 4, 0.75) # Returns 3.0
[/codeblock]
See also [method inverse_lerp] which performs the reverse of this operation. To perform eased interpolation with [method lerp], combine it with [method ease] or [method smoothstep]. See also [method remap] to map a continuous series of values to another.
[b]Note:[/b] For better type safety, use [method lerpf], [method Vector2.lerp], [method Vector3.lerp], [method Vector4.lerp], [method Color.lerp], [method Quaternion.slerp] or [method Basis.slerp].
Linearly interpolates between two angles (in radians) by a [param weight] value between 0.0 and 1.0.
Similar to [method lerp], but interpolates correctly when the angles wrap around [constant @GDScript.TAU]. To perform eased interpolation with [method lerp_angle], combine it with [method ease] or [method smoothstep].
[codeblock]
extends Sprite
var elapsed = 0.0
func _process(delta):
var min_angle = deg_to_rad(0.0)
var max_angle = deg_to_rad(90.0)
rotation = lerp_angle(min_angle, max_angle, elapsed)
elapsed += delta
[/codeblock]
[b]Note:[/b] This function lerps through the shortest path between [param from] and [param to]. However, when these two angles are approximately [code]PI + k * TAU[/code] apart for any integer [code]k[/code], it's not obvious which way they lerp due to floating-point precision errors. For example, [code]lerp_angle(0, PI, weight)[/code] lerps counter-clockwise, while [code]lerp_angle(0, PI + 5 * TAU, weight)[/code] lerps clockwise.
Linearly interpolates between two values by the factor defined in [param weight]. To perform interpolation, [param weight] should be between [code]0.0[/code] and [code]1.0[/code] (inclusive). However, values outside this range are allowed and can be used to perform [i]extrapolation[/i]. If this is not desired, use [method clampf] on the result of this function.
[codeblock]
lerpf(0, 4, 0.75) # Returns 3.0
[/codeblock]
See also [method inverse_lerp] which performs the reverse of this operation. To perform eased interpolation with [method lerp], combine it with [method ease] or [method smoothstep].
Converts from linear energy to decibels (audio). This can be used to implement volume sliders that behave as expected (since volume isn't linear).
[b]Example:[/b]
[codeblock]
# "Slider" refers to a node that inherits Range such as HSlider or VSlider.
# Its range must be configured to go from 0 to 1.
# Change the bus name if you'd like to change the volume of a specific bus only.
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), linear_to_db($Slider.value))
[/codeblock]
Returns the [url=https://en.wikipedia.org/wiki/Natural_logarithm]natural logarithm[/url] of [param x] (base [url=https://en.wikipedia.org/wiki/E_(mathematical_constant)][i]e[/i][/url], with [i]e[/i] being approximately 2.71828). This is the amount of time needed to reach a certain level of continuous growth.
[b]Note:[/b] This is not the same as the "log" function on most calculators, which uses a base 10 logarithm. To use base 10 logarithm, use [code]log(x) / log(10)[/code].
[codeblock]
log(10) # Returns 2.302585
[/codeblock]
[b]Note:[/b] The logarithm of [code]0[/code] returns [code]-inf[/code], while negative values return [code]-nan[/code].
Returns the maximum of the given numeric values. This function can take any number of arguments.
[codeblock]
max(1, 7, 3, -6, 5) # Returns 7
[/codeblock]
Returns the maximum of two [float] values.
[codeblock]
maxf(3.6, 24) # Returns 24.0
maxf(-3.99, -4) # Returns -3.99
[/codeblock]
Returns the maximum of two [int] values.
[codeblock]
maxi(1, 2) # Returns 2
maxi(-3, -4) # Returns -3
[/codeblock]
Returns the minimum of the given numeric values. This function can take any number of arguments.
[codeblock]
min(1, 7, 3, -6, 5) # Returns -6
[/codeblock]
Returns the minimum of two [float] values.
[codeblock]
minf(3.6, 24) # Returns 3.6
minf(-3.99, -4) # Returns -4.0
[/codeblock]
Returns the minimum of two [int] values.
[codeblock]
mini(1, 2) # Returns 1
mini(-3, -4) # Returns -4
[/codeblock]
Moves [param from] toward [param to] by the [param delta] value.
Use a negative [param delta] value to move away.
[codeblock]
move_toward(5, 10, 4) # Returns 9
move_toward(10, 5, 4) # Returns 6
move_toward(10, 5, -1.5) # Returns 11.5
[/codeblock]
Returns the nearest equal or larger power of 2 for the integer [param value].
In other words, returns the smallest value [code]a[/code] where [code]a = pow(2, n)[/code] such that [code]value <= a[/code] for some non-negative integer [code]n[/code].
[codeblock]
nearest_po2(3) # Returns 4
nearest_po2(4) # Returns 4
nearest_po2(5) # Returns 8
nearest_po2(0) # Returns 0 (this may not be expected)
nearest_po2(-1) # Returns 0 (this may not be expected)
[/codeblock]
[b]Warning:[/b] Due to the way it is implemented, this function returns [code]0[/code] rather than [code]1[/code] for negative values of [param value] (in reality, 1 is the smallest integer power of 2).
Wraps [param value] between [code]0[/code] and the [param length]. If the limit is reached, the next value the function returns is decreased to the [code]0[/code] side or increased to the [param length] side (like a triangle wave). If [param length] is less than zero, it becomes positive.
[codeblock]
pingpong(-3.0, 3.0) # Returns 3.0
pingpong(-2.0, 3.0) # Returns 2.0
pingpong(-1.0, 3.0) # Returns 1.0
pingpong(0.0, 3.0) # Returns 0.0
pingpong(1.0, 3.0) # Returns 1.0
pingpong(2.0, 3.0) # Returns 2.0
pingpong(3.0, 3.0) # Returns 3.0
pingpong(4.0, 3.0) # Returns 2.0
pingpong(5.0, 3.0) # Returns 1.0
pingpong(6.0, 3.0) # Returns 0.0
[/codeblock]
Returns the integer modulus of [param x] divided by [param y] that wraps equally in positive and negative.
[codeblock]
print("#(i) (i % 3) (posmod(i, 3))")
for i in range(-3, 4):
print("%2d %2d | %2d" % [i, i % 3, posmod(i, 3)])
[/codeblock]
Produces:
[codeblock]
(i) (i % 3) (posmod(i, 3))
-3 0 | 0
-2 -2 | 1
-1 -1 | 2
0 0 | 0
1 1 | 1
2 2 | 2
3 0 | 0
[/codeblock]
Returns the result of [param base] raised to the power of [param exp].
In GDScript, this is the equivalent of the [code]**[/code] operator.
[codeblock]
pow(2, 5) # Returns 32.0
pow(4, 1.5) # Returns 8.0
[/codeblock]
Converts one or more arguments of any type to string in the best way possible and prints them to the console.
[codeblocks]
[gdscript]
var a = [1, 2, 3]
print("a", "b", a) # Prints ab[1, 2, 3]
[/gdscript]
[csharp]
var a = new Godot.Collections.Array { 1, 2, 3 };
GD.Print("a", "b", a); // Prints ab[1, 2, 3]
[/csharp]
[/codeblocks]
[b]Note:[/b] Consider using [method push_error] and [method push_warning] to print error and warning messages instead of [method print] or [method 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.
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: [code]b[/code], [code]i[/code], [code]u[/code], [code]s[/code], [code]indent[/code], [code]code[/code], [code]url[/code], [code]center[/code], [code]right[/code], [code]color[/code], [code]bgcolor[/code], [code]fgcolor[/code].
Color tags only support the following named colors: [code]black[/code], [code]red[/code], [code]green[/code], [code]yellow[/code], [code]blue[/code], [code]magenta[/code], [code]pink[/code], [code]purple[/code], [code]cyan[/code], [code]white[/code], [code]orange[/code], [code]gray[/code]. 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]code[/code] is represented with faint text but without any font change. Unsupported tags are left as-is in standard output.
[codeblocks]
[gdscript]
print_rich("[color=green][b]Hello world![/b][/color]") # Prints out "Hello world!" in green with a bold font
[/gdscript]
[csharp]
GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints out "Hello world!" in green with a bold font
[/csharp]
[/codeblocks]
[b]Note:[/b] Consider using [method push_error] and [method push_warning] to print error and warning messages instead of [method print] or [method 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.
[b]Note:[/b] On Windows, only Windows 10 and later correctly displays ANSI escape codes in standard output.
If verbose mode is enabled ([method OS.is_stdout_verbose] returning [code]true[/code]), converts one or more arguments of any type to string in the best way possible and prints them to the console.
Prints one or more arguments to strings in the best way possible to standard error line.
[codeblocks]
[gdscript]
printerr("prints to stderr")
[/gdscript]
[csharp]
GD.PrintErr("prints to stderr");
[/csharp]
[/codeblocks]
Prints one or more arguments to strings in the best way possible to the OS terminal. Unlike [method print], no newline is automatically added at the end.
[codeblocks]
[gdscript]
printraw("A")
printraw("B")
printraw("C")
# Prints ABC to terminal
[/gdscript]
[csharp]
GD.PrintRaw("A");
GD.PrintRaw("B");
GD.PrintRaw("C");
// Prints ABC to terminal
[/csharp]
[/codeblocks]
Prints one or more arguments to the console with a space between each argument.
[codeblocks]
[gdscript]
prints("A", "B", "C") # Prints A B C
[/gdscript]
[csharp]
GD.PrintS("A", "B", "C"); // Prints A B C
[/csharp]
[/codeblocks]
Prints one or more arguments to the console with a tab between each argument.
[codeblocks]
[gdscript]
printt("A", "B", "C") # Prints A B C
[/gdscript]
[csharp]
GD.PrintT("A", "B", "C"); // Prints A B C
[/csharp]
[/codeblocks]
Pushes an error message to Godot's built-in debugger and to the OS terminal.
[codeblocks]
[gdscript]
push_error("test error") # Prints "test error" to debugger and terminal as error call
[/gdscript]
[csharp]
GD.PushError("test error"); // Prints "test error" to debugger and terminal as error call
[/csharp]
[/codeblocks]
[b]Note:[/b] This function does not pause project execution. To print an error message and pause project execution in debug builds, use [code]assert(false, "test error")[/code] instead.
Pushes a warning message to Godot's built-in debugger and to the OS terminal.
[codeblocks]
[gdscript]
push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call
[/gdscript]
[csharp]
GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as warning call
[/csharp]
[/codeblocks]
Converts an angle expressed in radians to degrees.
[codeblock]
rad_to_deg(0.523599) # Returns 30
rad_to_deg(PI) # Returns 180
rad_to_deg(PI * 2) # Returns 360
[/codeblock]
Given a [param seed], returns a [PackedInt64Array] of size [code]2[/code], where its first element is the randomized [int] value, and the second element is the same as [param seed]. Passing the same [param seed] consistently returns the same array.
[b]Note:[/b] "Seed" here refers to the internal state of the pseudo random number generator, currently implemented as a 64 bit integer.
[codeblock]
var a = rand_from_seed(4)
print(a[0]) # Prints 2879024997
print(a[1]) # Prints 4
[/codeblock]
Returns a random floating point value between [code]0.0[/code] and [code]1.0[/code] (inclusive).
[codeblocks]
[gdscript]
randf() # Returns e.g. 0.375671
[/gdscript]
[csharp]
GD.Randf(); // Returns e.g. 0.375671
[/csharp]
[/codeblocks]
Returns a random floating point value between [param from] and [param to] (inclusive).
[codeblocks]
[gdscript]
randf_range(0, 20.5) # Returns e.g. 7.45315
randf_range(-10, 10) # Returns e.g. -3.844535
[/gdscript]
[csharp]
GD.RandRange(0.0, 20.5); // Returns e.g. 7.45315
GD.RandRange(-10.0, 10.0); // Returns e.g. -3.844535
[/csharp]
[/codeblocks]
Returns a normally-distributed pseudo-random floating point value using Box-Muller transform with the specified [param mean] and a standard [param deviation]. This is also called Gaussian distribution.
Returns a random unsigned 32-bit integer. Use remainder to obtain a random value in the interval [code][0, N - 1][/code] (where N is smaller than 2^32).
[codeblocks]
[gdscript]
randi() # Returns random integer between 0 and 2^32 - 1
randi() % 20 # Returns random integer between 0 and 19
randi() % 100 # Returns random integer between 0 and 99
randi() % 100 + 1 # Returns random integer between 1 and 100
[/gdscript]
[csharp]
GD.Randi(); // Returns random integer between 0 and 2^32 - 1
GD.Randi() % 20; // Returns random integer between 0 and 19
GD.Randi() % 100; // Returns random integer between 0 and 99
GD.Randi() % 100 + 1; // Returns random integer between 1 and 100
[/csharp]
[/codeblocks]
Returns a random signed 32-bit integer between [param from] and [param to] (inclusive). If [param to] is lesser than [param from], they are swapped.
[codeblocks]
[gdscript]
randi_range(0, 1) # Returns either 0 or 1
randi_range(-10, 1000) # Returns random integer between -10 and 1000
[/gdscript]
[csharp]
GD.RandRange(0, 1); // Returns either 0 or 1
GD.RandRange(-10, 1000); // Returns random integer between -10 and 1000
[/csharp]
[/codeblocks]
Randomizes the seed (or the internal state) of the random number generator. The current implementation uses a number based on the device's time.
[b]Note:[/b] This function is called automatically when the project is run. If you need to fix the seed to have consistent, reproducible results, use [method seed] to initialize the random number generator.
Maps a [param value] from range [code][istart, istop][/code] to [code][ostart, ostop][/code]. See also [method lerp] and [method inverse_lerp]. If [param value] is outside [code][istart, istop][/code], then the resulting value will also be outside [code][ostart, ostop][/code]. If this is not desired, use [method clamp] on the result of this function.
[codeblock]
remap(75, 0, 100, -1, 1) # Returns 0.5
[/codeblock]
For complex use cases where multiple ranges are needed, consider using [Curve] or [Gradient] instead.
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.
Creates a RID from a [param base]. This is used mainly from native extensions to build servers.
Rounds [param x] to the nearest whole number, with halfway cases rounded away from 0. Supported types: [int], [float], [Vector2], [Vector3], [Vector4].
[codeblock]
round(2.4) # Returns 2
round(2.5) # Returns 3
round(2.6) # Returns 3
[/codeblock]
See also [method floor], [method ceil], and [method snapped].
[b]Note:[/b] For better type safety, use [method roundf], [method roundi], [method Vector2.round], [method Vector3.round], or [method Vector4.round].
Rounds [param x] to the nearest whole number, with halfway cases rounded away from 0.
A type-safe version of [method round], returning a [float].
Rounds [param x] to the nearest whole number, with halfway cases rounded away from 0.
A type-safe version of [method round], returning an [int].
Sets the seed for the random number generator to [param base]. Setting the seed manually can ensure consistent, repeatable results for most random functions.
[codeblocks]
[gdscript]
var my_seed = "Godot Rocks".hash()
seed(my_seed)
var a = randf() + randi()
seed(my_seed)
var b = randf() + randi()
# a and b are now identical
[/gdscript]
[csharp]
ulong mySeed = (ulong)GD.Hash("Godot Rocks");
GD.Seed(mySeed);
var a = GD.Randf() + GD.Randi();
GD.Seed(mySeed);
var b = GD.Randf() + GD.Randi();
// a and b are now identical
[/csharp]
[/codeblocks]
Returns the same type of [Variant] as [param x], with [code]-1[/code] for negative values, [code]1[/code] for positive values, and [code]0[/code] for zeros. Supported types: [int], [float], [Vector2], [Vector2i], [Vector3], [Vector3i], [Vector4], [Vector4i].
[codeblock]
sign(-6.0) # Returns -1
sign(0.0) # Returns 0
sign(6.0) # Returns 1
sign(Vector3(-6.0, 0.0, 6.0)) # Returns (-1, 0, 1)
[/codeblock]
[b]Note:[/b] For better type safety, use [method signf], [method signi], [method Vector2.sign], [method Vector2i.sign], [method Vector3.sign], [method Vector3i.sign], [method Vector4.sign], or [method Vector4i.sign].
Returns [code]-1.0[/code] if [param x] is negative, [code]1.0[/code] if [param x] is positive, and [code]0.0[/code] if [param x] is zero.
[codeblock]
signf(-6.5) # Returns -1.0
signf(0.0) # Returns 0.0
signf(6.5) # Returns 1.0
[/codeblock]
Returns [code]-1[/code] if [param x] is negative, [code]1[/code] if [param x] is positive, and [code]0[/code] if if [param x] is zero.
[codeblock]
signi(-6) # Returns -1
signi(0) # Returns 0
signi(6) # Returns 1
[/codeblock]
Returns the sine of angle [param angle_rad] in radians.
[codeblock]
sin(0.523599) # Returns 0.5
sin(deg_to_rad(90)) # Returns 1.0
[/codeblock]
Returns the hyperbolic sine of [param x].
[codeblock]
var a = log(2.0) # Returns 0.693147
sinh(a) # Returns 0.75
[/codeblock]
Returns the result of smoothly interpolating the value of [param x] between [code]0[/code] and [code]1[/code], based on the where [param x] lies with respect to the edges [param from] and [param to].
The return value is [code]0[/code] if [code]x <= from[/code], and [code]1[/code] if [code]x >= to[/code]. If [param x] lies between [param from] and [param to], the returned value follows an S-shaped curve that maps [param x] between [code]0[/code] and [code]1[/code].
This S-shaped curve is the cubic Hermite interpolator, given by [code]f(y) = 3*y^2 - 2*y^3[/code] where [code]y = (x-from) / (to-from)[/code].
[codeblock]
smoothstep(0, 2, -5.0) # Returns 0.0
smoothstep(0, 2, 0.5) # Returns 0.15625
smoothstep(0, 2, 1.0) # Returns 0.5
smoothstep(0, 2, 2.0) # Returns 1.0
[/codeblock]
Compared to [method ease] with a curve value of [code]-1.6521[/code], [method 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].
[url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/smoothstep_ease_comparison.png]Comparison between smoothstep() and ease(x, -1.6521) return values[/url]
Returns the multiple of [param step] that is the closest to [param 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 [param step]. Supported types: [int], [float], [Vector2], [Vector2i], [Vector3], [Vector3i], [Vector4], [Vector4i].
[codeblock]
snapped(100, 32) # Returns 96
snapped(3.14159, 0.01) # Returns 3.14
snapped(Vector2(34, 70), Vector2(8, 8)) # Returns (32, 72)
[/codeblock]
See also [method ceil], [method floor], and [method round].
[b]Note:[/b] For better type safety, use [method snappedf], [method snappedi], [method Vector2.snapped], [method Vector2i.snapped], [method Vector3.snapped], [method Vector3i.snapped], [method Vector4.snapped], or [method Vector4i.snapped].
Returns the multiple of [param step] that is the closest to [param x]. This can also be used to round a floating point number to an arbitrary number of decimals.
A type-safe version of [method snapped], returning a [float].
[codeblock]
snappedf(32.0, 2.5) # Returns 32.5
snappedf(3.14159, 0.01) # Returns 3.14
[/codeblock]
Returns the multiple of [param step] that is the closest to [param x].
A type-safe version of [method snapped], returning an [int].
[codeblock]
snappedi(53, 16) # Returns 48
snappedi(4096, 100) # Returns 4100
[/codeblock]
Returns the square root of [param x], where [param x] is a non-negative number.
[codeblock]
sqrt(9) # Returns 3
sqrt(10.24) # Returns 3.2
sqrt(-1) # Returns NaN
[/codeblock]
[b]Note:[/b] Negative values of [param x] return NaN ("Not a Number"). in C#, if you need negative inputs, use [code]System.Numerics.Complex[/code].
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.
[codeblock]
var n = step_decimals(5) # n is 0
n = step_decimals(1.0005) # n is 4
n = step_decimals(0.000000005) # n is 9
[/codeblock]
Converts one or more arguments of any [Variant] type to a [String] in the best way possible.
[codeblock]
var a = [10, 20, 30]
var b = str(a)
print(len(a)) # Prints 3 (the number of elements in the array).
print(len(b)) # Prints 12 (the length of the string "[10, 20, 30]").
[/codeblock]
Converts a formatted [param string] that was returned by [method var_to_str] to the original [Variant].
[codeblocks]
[gdscript]
var data = '{ "a": 1, "b": 2 }' # data is a String
var dict = str_to_var(data) # dict is a Dictionary
print(dict["a"]) # Prints 1
[/gdscript]
[csharp]
string data = "{ \"a\": 1, \"b\": 2 }"; // data is a string
var dict = GD.StrToVar(data).AsGodotDictionary(); // dict is a Dictionary
GD.Print(dict["a"]); // Prints 1
[/csharp]
[/codeblocks]
Returns the tangent of angle [param angle_rad] in radians.
[codeblock]
tan(deg_to_rad(45)) # Returns 1
[/codeblock]
Returns the hyperbolic tangent of [param x].
[codeblock]
var a = log(2.0) # Returns 0.693147
tanh(a) # Returns 0.6
[/codeblock]
Returns the internal type of the given [param variable], using the [enum Variant.Type] values.
[codeblock]
var json = JSON.new()
json.parse('["a", "b", "c"]')
var result = json.get_data()
if typeof(result) == TYPE_ARRAY:
print(result[0]) # Prints a
else:
print("Unexpected result")
[/codeblock]
Encodes a [Variant] value to a byte array, without encoding objects. Deserialization can be done with [method bytes_to_var].
[b]Note:[/b] If you need object serialization, see [method var_to_bytes_with_objects].
Encodes a [Variant] value to a byte array. Encoding objects is allowed (and can potentially include executable code). Deserialization can be done with [method bytes_to_var_with_objects].
Converts a [Variant] [param variable] to a formatted [String] that can then be parsed using [method str_to_var].
[codeblocks]
[gdscript]
var a = { "a": 1, "b": 2 }
print(var_to_str(a))
[/gdscript]
[csharp]
var a = new Godot.Collections.Dictionary { ["a"] = 1, ["b"] = 2 };
GD.Print(GD.VarToStr(a));
[/csharp]
[/codeblocks]
Prints:
[codeblock]
{
"a": 1,
"b": 2
}
[/codeblock]
Returns a weak reference to an object, or [code]null[/code] if [param 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.
Wraps the [Variant] [param value] between [param min] and [param 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].
[codeblock]
var a = wrap(4, 5, 10)
# a is 9 (int)
var a = wrap(7, 5, 10)
# a is 7 (int)
var a = wrap(10.5, 5, 10)
# a is 5.5 (float)
[/codeblock]
Wraps the float [param value] between [param min] and [param max]. Can be used for creating loop-alike behavior or infinite surfaces.
[codeblock]
# Infinite loop between 5.0 and 9.9
value = wrapf(value + 0.1, 5.0, 10.0)
[/codeblock]
[codeblock]
# Infinite rotation (in radians)
angle = wrapf(angle + 0.1, 0.0, TAU)
[/codeblock]
[codeblock]
# Infinite rotation (in radians)
angle = wrapf(angle + 0.1, -PI, PI)
[/codeblock]
[b]Note:[/b] If [param min] is [code]0[/code], this is equivalent to [method fposmod], so prefer using that instead.
[code]wrapf[/code] is more flexible than using the [method fposmod] approach by giving the user control over the minimum value.
Wraps the integer [param value] between [param min] and [param max]. Can be used for creating loop-alike behavior or infinite surfaces.
[codeblock]
# Infinite loop between 5 and 9
frame = wrapi(frame + 1, 5, 10)
[/codeblock]
[codeblock]
# result is -2
var result = wrapi(-6, -5, -1)
[/codeblock]
The [AudioServer] singleton.
The [CameraServer] singleton.
The [ClassDB] singleton.
The [DisplayServer] singleton.
The [Engine] singleton.
The [EngineDebugger] singleton.
The [GDExtensionManager] singleton.
The [Geometry2D] singleton.
The [Geometry3D] singleton.
The [GodotSharp] singleton.
The [IP] singleton.
The [Input] singleton.
The [InputMap] singleton.
The [JavaClassWrapper] singleton.
[b]Note:[/b] Only implemented on Android.
The [JavaScriptBridge] singleton.
[b]Note:[/b] Only implemented on the Web platform.
The [Marshalls] singleton.
The [NavigationMeshGenerator] singleton.
The [NavigationServer2D] singleton.
The [NavigationServer2D] singleton.
The [OS] singleton.
The [Performance] singleton.
The [PhysicsServer2D] singleton.
The [PhysicsServer2DManager] singleton.
The [PhysicsServer3D] singleton.
The [PhysicsServer3DManager] singleton.
The [ProjectSettings] singleton.
The [RenderingServer] singleton.
The [ResourceLoader] singleton.
The [ResourceSaver] singleton.
The [ResourceUID] singleton.
The [TextServerManager] singleton.
The [ThemeDB] singleton.
The [Time] singleton.
The [TranslationServer] singleton.
The [WorkerThreadPool] singleton.
The [XRServer] singleton.
Left side, usually used for [Control] or [StyleBox]-derived classes.
Top side, usually used for [Control] or [StyleBox]-derived classes.
Right side, usually used for [Control] or [StyleBox]-derived classes.
Bottom side, usually used for [Control] or [StyleBox]-derived classes.
Top-left corner.
Top-right corner.
Bottom-right corner.
Bottom-left corner.
General vertical alignment, usually used for [Separator], [ScrollBar], [Slider], etc.
General horizontal alignment, usually used for [Separator], [ScrollBar], [Slider], etc.
Clockwise rotation. Used by some methods (e.g. [method Image.rotate_90]).
Counter-clockwise rotation. Used by some methods (e.g. [method Image.rotate_90]).
Horizontal left alignment, usually for text-derived classes.
Horizontal center alignment, usually for text-derived classes.
Horizontal right alignment, usually for text-derived classes.
Expand row to fit width, usually for text-derived classes.
Vertical top alignment, usually for text-derived classes.
Vertical center alignment, usually for text-derived classes.
Vertical bottom alignment, usually for text-derived classes.
Expand rows to fit height, usually for text-derived classes.
Aligns the top of the inline object (e.g. image, table) to the position of the text specified by [code]INLINE_ALIGNMENT_TO_*[/code] constant.
Aligns the center of the inline object (e.g. image, table) to the position of the text specified by [code]INLINE_ALIGNMENT_TO_*[/code] constant.
Aligns the baseline (user defined) of the inline object (e.g. image, table) to the position of the text specified by [code]INLINE_ALIGNMENT_TO_*[/code] constant.
Aligns the bottom of the inline object (e.g. image, table) to the position of the text specified by [code]INLINE_ALIGNMENT_TO_*[/code] constant.
Aligns the position of the inline object (e.g. image, table) specified by [code]INLINE_ALIGNMENT_*_TO[/code] constant to the top of the text.
Aligns the position of the inline object (e.g. image, table) specified by [code]INLINE_ALIGNMENT_*_TO[/code] constant to the center of the text.
Aligns the position of the inline object (e.g. image, table) specified by [code]INLINE_ALIGNMENT_*_TO[/code] constant to the baseline of the text.
Aligns inline object (e.g. image, table) to the bottom of the text.
Aligns top of the inline object (e.g. image, table) to the top of the text. Equivalent to [code]INLINE_ALIGNMENT_TOP_TO | INLINE_ALIGNMENT_TO_TOP[/code].
Aligns center of the inline object (e.g. image, table) to the center of the text. Equivalent to [code]INLINE_ALIGNMENT_CENTER_TO | INLINE_ALIGNMENT_TO_CENTER[/code].
Aligns bottom of the inline object (e.g. image, table) to the bottom of the text. Equivalent to [code]INLINE_ALIGNMENT_BOTTOM_TO | INLINE_ALIGNMENT_TO_BOTTOM[/code].
A bit mask for [code]INLINE_ALIGNMENT_*_TO[/code] alignment constants.
A bit mask for [code]INLINE_ALIGNMENT_TO_*[/code] alignment constants.
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.
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.
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.
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.
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.
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 value which doesn't correspond to any key. This is used to initialize [enum Key] properties with a generic state.
Keycodes with this bit applied are non-printable.
Escape key.
Tab key.
Shift + Tab key.
Backspace key.
Return key (on the main keyboard).
Enter key on the numeric keypad.
Insert key.
Delete key.
Pause key.
Print Screen key.
System Request key.
Clear key.
Home key.
End key.
Left arrow key.
Up arrow key.
Right arrow key.
Down arrow key.
Page Up key.
Page Down key.
Shift key.
Control key.
Meta key.
Alt key.
Caps Lock key.
Num Lock key.
Scroll Lock key.
F1 key.
F2 key.
F3 key.
F4 key.
F5 key.
F6 key.
F7 key.
F8 key.
F9 key.
F10 key.
F11 key.
F12 key.
F13 key.
F14 key.
F15 key.
F16 key.
F17 key.
F18 key.
F19 key.
F20 key.
F21 key.
F22 key.
F23 key.
F24 key.
F25 key. Only supported on macOS and Linux due to a Windows limitation.
F26 key. Only supported on macOS and Linux due to a Windows limitation.
F27 key. Only supported on macOS and Linux due to a Windows limitation.
F28 key. Only supported on macOS and Linux due to a Windows limitation.
F29 key. Only supported on macOS and Linux due to a Windows limitation.
F30 key. Only supported on macOS and Linux due to a Windows limitation.
F31 key. Only supported on macOS and Linux due to a Windows limitation.
F32 key. Only supported on macOS and Linux due to a Windows limitation.
F33 key. Only supported on macOS and Linux due to a Windows limitation.
F34 key. Only supported on macOS and Linux due to a Windows limitation.
F35 key. Only supported on macOS and Linux due to a Windows limitation.
Multiply (*) key on the numeric keypad.
Divide (/) key on the numeric keypad.
Subtract (-) key on the numeric keypad.
Period (.) key on the numeric keypad.
Add (+) key on the numeric keypad.
Number 0 on the numeric keypad.
Number 1 on the numeric keypad.
Number 2 on the numeric keypad.
Number 3 on the numeric keypad.
Number 4 on the numeric keypad.
Number 5 on the numeric keypad.
Number 6 on the numeric keypad.
Number 7 on the numeric keypad.
Number 8 on the numeric keypad.
Number 9 on the numeric keypad.
Context menu key.
Hyper key. (On Linux/X11 only).
Help key.
Media back key. Not to be confused with the Back button on an Android device.
Media forward key.
Media stop key.
Media refresh key.
Volume down key.
Mute volume key.
Volume up key.
Media play key.
Media stop key.
Previous song key.
Next song key.
Media record key.
Home page key.
Favorites key.
Search key.
Standby key.
Open URL / Launch Browser key.
Launch Mail key.
Launch Media key.
Launch Shortcut 0 key.
Launch Shortcut 1 key.
Launch Shortcut 2 key.
Launch Shortcut 3 key.
Launch Shortcut 4 key.
Launch Shortcut 5 key.
Launch Shortcut 6 key.
Launch Shortcut 7 key.
Launch Shortcut 8 key.
Launch Shortcut 9 key.
Launch Shortcut A key.
Launch Shortcut B key.
Launch Shortcut C key.
Launch Shortcut D key.
Launch Shortcut E key.
Launch Shortcut F key.
Unknown key.
Space key.
! key.
" key.
# key.
$ key.
% key.
& key.
' key.
( key.
) key.
* key.
+ key.
, key.
- key.
. key.
/ key.
Number 0 key.
Number 1 key.
Number 2 key.
Number 3 key.
Number 4 key.
Number 5 key.
Number 6 key.
Number 7 key.
Number 8 key.
Number 9 key.
: key.
; key.
< key.
= key.
> key.
? key.
@ key.
A key.
B key.
C key.
D key.
E key.
F key.
G key.
H key.
I key.
J key.
K key.
L key.
M key.
N key.
O key.
P key.
Q key.
R key.
S key.
T key.
U key.
V key.
W key.
X key.
Y key.
Z key.
[ key.
\ key.
] key.
^ key.
_ key.
` key.
{ key.
| key.
} key.
~ key.
¥ key.
§ key.
"Globe" key on Mac / iPad keyboard.
"On-screen keyboard" key iPad keyboard.
英数 key on Mac keyboard.
かな key on Mac keyboard.
Key Code mask.
Modifier key mask.
Automatically remapped to [constant KEY_META] on macOS and [constant KEY_CTRL] on other platforms, this mask is never set in the actual events, and should be used for key mapping only.
Shift key mask.
Alt or Option (on macOS) key mask.
Command (on macOS) or Meta/Windows key mask.
Control key mask.
Keypad key mask.
Group Switch key mask.
Enum value which doesn't correspond to any mouse button. This is used to initialize [enum MouseButton] properties with a generic state.
Primary mouse button, usually assigned to the left button.
Secondary mouse button, usually assigned to the right button.
Middle mouse button.
Mouse wheel scrolling up.
Mouse wheel scrolling down.
Mouse wheel left button (only present on some mice).
Mouse wheel right button (only present on some mice).
Extra mouse button 1. This is sometimes present, usually to the sides of the mouse.
Extra mouse button 2. This is sometimes present, usually to the sides of the mouse.
Primary mouse button mask, usually for the left button.
Secondary mouse button mask, usually for the right button.
Middle mouse button mask.
Extra mouse button 1 mask.
Extra mouse button 2 mask.
An invalid game controller button.
Game controller SDL button A. Corresponds to the bottom action button: Sony Cross, Xbox A, Nintendo B.
Game controller SDL button B. Corresponds to the right action button: Sony Circle, Xbox B, Nintendo A.
Game controller SDL button X. Corresponds to the left action button: Sony Square, Xbox X, Nintendo Y.
Game controller SDL button Y. Corresponds to the top action button: Sony Triangle, Xbox Y, Nintendo X.
Game controller SDL back button. Corresponds to the Sony Select, Xbox Back, Nintendo - button.
Game controller SDL guide button. Corresponds to the Sony PS, Xbox Home button.
Game controller SDL start button. Corresponds to the Nintendo + button.
Game controller SDL left stick button. Corresponds to the Sony L3, Xbox L/LS button.
Game controller SDL right stick button. Corresponds to the Sony R3, Xbox R/RS button.
Game controller SDL left shoulder button. Corresponds to the Sony L1, Xbox LB button.
Game controller SDL right shoulder button. Corresponds to the Sony R1, Xbox RB button.
Game controller D-pad up button.
Game controller D-pad down button.
Game controller D-pad left button.
Game controller D-pad right button.
Game controller SDL miscellaneous button. Corresponds to Xbox share button, PS5 microphone button, Nintendo Switch capture button.
Game controller SDL paddle 1 button.
Game controller SDL paddle 2 button.
Game controller SDL paddle 3 button.
Game controller SDL paddle 4 button.
Game controller SDL touchpad button.
The number of SDL game controller buttons.
The maximum number of game controller buttons supported by the engine. The actual limit may be lower on specific platforms:
- [b]Android:[/b] Up to 36 buttons.
- [b]Linux:[/b] Up to 80 buttons.
- [b]Windows[/b] and [b]macOS:[/b] Up to 128 buttons.
An invalid game controller axis.
Game controller left joystick x-axis.
Game controller left joystick y-axis.
Game controller right joystick x-axis.
Game controller right joystick y-axis.
Game controller left trigger axis.
Game controller right trigger axis.
The number of SDL game controller axes.
The maximum number of game controller axes: OpenVR supports up to 5 Joysticks making a total of 10 axes.
Enum value which doesn't correspond to any MIDI message. This is used to initialize [enum MIDIMessage] properties with a generic state.
MIDI note OFF message. Not all MIDI devices send this event; some send [constant MIDI_MESSAGE_NOTE_ON] with zero velocity instead. See the documentation of [InputEventMIDI] for information of how to use MIDI inputs.
MIDI note ON message. Some MIDI devices send this event with velocity zero instead of [constant MIDI_MESSAGE_NOTE_OFF], but implementations vary. See the documentation of [InputEventMIDI] for information of how to use MIDI inputs.
MIDI aftertouch message. This message is most often sent by pressing down on the key after it "bottoms out".
MIDI control change message. This message is sent when a controller value changes. Controllers include devices such as pedals and levers.
MIDI program change message. This message sent when the program patch number changes.
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.
MIDI pitch bend message. This message is sent to indicate a change in the pitch bender (wheel or lever, typically).
MIDI system exclusive message. This has behavior exclusive to the device you're receiving input from. Getting this data is not implemented in Godot.
MIDI quarter frame message. Contains timing information that is used to synchronize MIDI devices. Getting this data is not implemented in Godot.
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.
MIDI song select message. Specifies which sequence or song is to be played. Getting this data is not implemented in Godot.
MIDI tune request message. Upon receiving a tune request, all analog synthesizers should tune their oscillators.
MIDI timing clock message. Sent 24 times per quarter note when synchronization is required.
MIDI start message. Start the current sequence playing. This message will be followed with Timing Clocks.
MIDI continue message. Continue at the point the sequence was stopped.
MIDI stop message. Stop the current sequence.
MIDI active sensing message. This message is intended to be sent repeatedly to tell the receiver that a connection is alive.
MIDI system reset message. Reset all receivers in the system to power-up status. It should not be sent on power-up itself.
Methods that return [enum Error] return [constant OK] when no error occurred.
Since [constant OK] has value 0, and all other error constants are positive integers, it can also be used in boolean checks.
[b]Example:[/b]
[codeblock]
var error = method_that_returns_error()
if error != OK:
printerr("Failure!")
# Or, alternatively:
if error:
printerr("Still failing!")
[/codeblock]
[b]Note:[/b] Many functions do not return an error code, but will print error messages to standard output.
Generic error.
Unavailable error.
Unconfigured error.
Unauthorized error.
Parameter range error.
Out of memory (OOM) error.
File: Not found error.
File: Bad drive error.
File: Bad path error.
File: No permission error.
File: Already in use error.
File: Can't open error.
File: Can't write error.
File: Can't read error.
File: Unrecognized error.
File: Corrupt error.
File: Missing dependencies error.
File: End of file (EOF) error.
Can't open error.
Can't create error.
Query failed error.
Already in use error.
Locked error.
Timeout error.
Can't connect error.
Can't resolve error.
Connection error.
Can't acquire resource error.
Can't fork process error.
Invalid data error.
Invalid parameter error.
Already exists error.
Does not exist error.
Database: Read error.
Database: Write error.
Compilation failed error.
Method not found error.
Linking failed error.
Script failed error.
Cycling link (import cycle) error.
Invalid declaration error.
Duplicate symbol error.
Parse error.
Busy error.
Skip error.
Help error. Used internally when passing [code]--version[/code] or [code]--help[/code] as executable options.
Bug error, caused by an implementation issue in the method.
[b]Note:[/b] If a built-in method returns this code, please open an issue on [url=https://github.com/godotengine/godot/issues]the GitHub Issue Tracker[/url].
Printer on fire error (This is an easter egg, no built-in methods return this error code).
The property has no hint for the editor.
Hints that an [int] or [float] property should be within a range specified via the hint string [code]"min,max"[/code] or [code]"min,max,step"[/code]. The hint string can optionally include [code]"or_greater"[/code] and/or [code]"or_less"[/code] to allow manual input going respectively above the max or below the min values.
[b]Example:[/b] [code]"-360,360,1,or_greater,or_less"[/code].
Additionally, other keywords can be included: [code]"exp"[/code] for exponential range editing, [code]"radians"[/code] for editing radian angles in degrees, [code]"degrees"[/code] to hint at an angle and [code]"hide_slider"[/code] to hide the slider.
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 [code]"Hello,Something,Else"[/code]. Whitespaces are [b]not[/b] 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 [code]:integer[/code] to the name, e.g. [code]"Zero,One,Three:3,Four,Six:6"[/code].
Hints that a [String] property can be an enumerated value to pick in a list specified via a hint string such as [code]"Hello,Something,Else"[/code].
Unlike [constant 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.
Hints that a [float] property should be edited via an exponential easing function. The hint string can include [code]"attenuation"[/code] to flip the curve horizontally and/or [code]"positive_only"[/code] to exclude in/out easing and limit values to be greater than or equal to zero.
Hints that a vector property should allow its components to be linked. For example, this allows [member Vector2.x] and [member Vector2.y] to be edited together.
Hints that an [int] property is a bitmask with named bit flags.
The hint string is a comma separated list of names such as [code]"Bit0,Bit1,Bit2,Bit3"[/code]. Whitespaces are [b]not[/b] 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 [code]:integer[/code] to the name, e.g. [code]"A:4,B:8,C:16"[/code]. You can also combine several flags ([code]"A:4,B:8,AB:12,C:16"[/code]).
[b]Note:[/b] A flag value must be at least [code]1[/code] and at most [code]2 ** 32 - 1[/code].
[b]Note:[/b] Unlike [constant PROPERTY_HINT_ENUM], the previous explicit value is not taken into account. For the hint [code]"A:16,B,C"[/code], A is 16, B is 2, C is 4.
Hints that an [int] property is a bitmask using the optionally named 2D render layers.
Hints that an [int] property is a bitmask using the optionally named 2D physics layers.
Hints that an [int] property is a bitmask using the optionally named 2D navigation layers.
Hints that an [int] property is a bitmask using the optionally named 3D render layers.
Hints that an [int] property is a bitmask using the optionally named 3D physics layers.
Hints that an [int] property is a bitmask using the optionally named 3D navigation layers.
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 [code]"*.png,*.jpg"[/code].
Hints that a [String] property is a path to a directory. Editing it will show a file dialog for picking the path.
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 [code]"*.png,*.jpg"[/code].
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.
Hints that a property is an instance of a [Resource]-derived type, optionally specified via the hint string (e.g. [code]"Texture2D"[/code]). Editing it will show a popup menu of valid resource types to instantiate.
Hints that a [String] property is text with line breaks. Editing it will show a text input field where line breaks can be typed.
Hints that a [String] property is an [Expression].
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.
Hints that a [Color] property should be edited without affecting its transparency ([member Color.a] is not editable).
Hint that a property represents a particular type. If a property is [constant TYPE_STRING], allows to set a type from the create dialog. If you need to create an [Array] to contain elements of a specific type, the [code]hint_string[/code] must encode nested types using [code]":"[/code] and [code]"/"[/code] for specifying [Resource] types. For instance:
[codeblock]
hint_string = "%s:" % [TYPE_INT] # Array of integers.
hint_string = "%s:%s:" % [TYPE_ARRAY, TYPE_REAL] # Two-dimensional array of floats.
hint_string = "%s/%s:Resource" % [TYPE_OBJECT, TYPE_OBJECT] # Array of resources.
hint_string = "%s:%s/%s:Resource" % [TYPE_ARRAY, TYPE_OBJECT, TYPE_OBJECT] # Two-dimensional array of resources.
[/codeblock]
[b]Note:[/b] The final colon is required for properly detecting built-in types.
Hints that a string property is a locale code. Editing it will show a locale dialog for picking language and country.
Hints that a dictionary property is string translation map. Dictionary keys are locale codes and, values are translated strings.
Hints that a quaternion property should disable the temporary euler editor.
Hints that a string property is a password, and every character is replaced with the secret character.
Represents the size of the [enum PropertyHint] enum.
The property is not stored, and does not display in the editor. This is the default for non-exported properties.
The property is serialized and saved in the scene file (default).
The property is shown in the [EditorInspector] (default).
The property is excluded from the class reference.
The property can be checked in the [EditorInspector].
The property is checked in the [EditorInspector].
Used to group properties together in the editor. See [EditorInspector].
Used to categorize properties together in the editor.
Used to group properties together in the editor in a subgroup (under a group). See [EditorInspector].
The property does not save its state in [PackedScene].
Editing the property prompts the user for restarting the editor.
The property is a script variable which should be serialized and saved in the scene file.
The property is an array.
When duplicating a resource with [method Resource.duplicate], and this flag is set on a property of that resource, the property should always be duplicated, regardless of the [code]subresources[/code] bool parameter.
When duplicating a resource with [method Resource.duplicate], and this flag is set on a property of that resource, the property should never be duplicated, regardless of the [code]subresources[/code] bool parameter.
The property is only shown in the editor if modern renderers are supported (the Compatibility rendering method is excluded).
The property is read-only in the [EditorInspector].
Default usage (storage and editor).
Default usage but without showing the property in the editor (storage).
Flag for a normal method.
Flag for an editor method.
Flag for a constant method.
Flag for a virtual method.
Flag for a method with a variable number of arguments.
Flag for a static method.
Used internally. Allows to not dump core virtual methods (such as [method Object._notification]) to the JSON API.
Default method flags (normal).
Variable is [code]null[/code].
Variable is of type [bool].
Variable is of type [int].
Variable is of type [float].
Variable is of type [String].
Variable is of type [Vector2].
Variable is of type [Vector2i].
Variable is of type [Rect2].
Variable is of type [Rect2i].
Variable is of type [Vector3].
Variable is of type [Vector3i].
Variable is of type [Transform2D].
Variable is of type [Vector4].
Variable is of type [Vector4i].
Variable is of type [Plane].
Variable is of type [Quaternion].
Variable is of type [AABB].
Variable is of type [Basis].
Variable is of type [Transform3D].
Variable is of type [Projection].
Variable is of type [Color].
Variable is of type [StringName].
Variable is of type [NodePath].
Variable is of type [RID].
Variable is of type [Object].
Variable is of type [Callable].
Variable is of type [Signal].
Variable is of type [Dictionary].
Variable is of type [Array].
Variable is of type [PackedByteArray].
Variable is of type [PackedInt32Array].
Variable is of type [PackedInt64Array].
Variable is of type [PackedFloat32Array].
Variable is of type [PackedFloat64Array].
Variable is of type [PackedStringArray].
Variable is of type [PackedVector2Array].
Variable is of type [PackedVector3Array].
Variable is of type [PackedColorArray].
Represents the size of the [enum Variant.Type] enum.
Equality operator ([code]==[/code]).
Inequality operator ([code]!=[/code]).
Less than operator ([code]<[/code]).
Less than or equal operator ([code]<=[/code]).
Greater than operator ([code]>[/code]).
Greater than or equal operator ([code]>=[/code]).
Addition operator ([code]+[/code]).
Subtraction operator ([code]-[/code]).
Multiplication operator ([code]*[/code]).
Division operator ([code]/[/code]).
Unary negation operator ([code]-[/code]).
Unary plus operator ([code]+[/code]).
Remainder/modulo operator ([code]%[/code]).
Power operator ([code]**[/code]).
Left shift operator ([code]<<[/code]).
Right shift operator ([code]>>[/code]).
Bitwise AND operator ([code]&[/code]).
Bitwise OR operator ([code]|[/code]).
Bitwise XOR operator ([code]^[/code]).
Bitwise NOT operator ([code]~[/code]).
Logical AND operator ([code]and[/code] or [code]&&[/code]).
Logical OR operator ([code]or[/code] or [code]||[/code]).
Logical XOR operator (not implemented in GDScript).
Logical NOT operator ([code]not[/code] or [code]![/code]).
Logical IN operator ([code]in[/code]).
Represents the size of the [enum Variant.Operator] enum.