GodotSharp
Axis-Aligned Bounding Box. AABB consists of a position, a size, and
several utility functions. It is typically used for fast overlap tests.
Beginning corner. Typically has values lower than .
Directly uses a private field.
Size from to . Typically all components are positive.
If the size is negative, you can use to fix it.
Directly uses a private field.
Ending corner. This is calculated as plus
. Setting this value will change the size.
Getting is equivalent to = + ,
setting is equivalent to = -
Returns an with equivalent position and size, modified so that
the most-negative corner is the origin and the size is positive.
The modified .
Returns the center of the , which is equal
to + ( / 2).
The center.
Returns if this completely encloses another one.
The other that may be enclosed.
A for whether or not this encloses .
Returns this expanded to include a given point.
The point to include.
The expanded .
Returns the area of the .
The area.
Gets the position of one of the 8 endpoints of the .
Which endpoint to get.
An endpoint of the .
Returns the normalized longest axis of the .
A vector representing the normalized longest axis of the .
Returns the index of the longest axis of the .
A index for which axis is longest.
Returns the scalar length of the longest axis of the .
The scalar length of the longest axis of the .
Returns the normalized shortest axis of the .
A vector representing the normalized shortest axis of the .
Returns the index of the shortest axis of the .
A index for which axis is shortest.
Returns the scalar length of the shortest axis of the .
The scalar length of the shortest axis of the .
Returns the support point in a given direction.
This is useful for collision detection algorithms.
The direction to find support for.
A vector representing the support.
Returns a copy of the grown a given amount of units towards all the sides.
The amount to grow by.
The grown .
Returns if the is flat or empty,
or otherwise.
A for whether or not the has area.
Returns if the has no surface (no size),
or otherwise.
A for whether or not the has area.
Returns if the contains a point,
or otherwise.
The point to check.
A for whether or not the contains .
Returns the intersection of this and .
The other .
The clipped .
Returns if the overlaps with
(i.e. they have at least one point in common).
If is ,
they will also be considered overlapping if their borders touch,
even without intersection.
The other to check for intersections with.
Whether or not to consider borders.
A for whether or not they are intersecting.
Returns if the is on both sides of .
The to check for intersection.
A for whether or not the intersects the .
Returns if the intersects
the line segment between and .
The start of the line segment.
The end of the line segment.
A for whether or not the intersects the line segment.
Returns a larger that contains this and .
The other .
The merged .
Constructs an from a position and size.
The position.
The size, typically positive.
Constructs an from a ,
, , and .
The position.
The width, typically positive.
The height, typically positive.
The depth, typically positive.
Constructs an from ,
, , and .
The position's X coordinate.
The position's Y coordinate.
The position's Z coordinate.
The size, typically positive.
Constructs an from ,
, , ,
, and .
The position's X coordinate.
The position's Y coordinate.
The position's Z coordinate.
The width, typically positive.
The height, typically positive.
The depth, typically positive.
Returns if the AABBs are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left AABB.
The right AABB.
Whether or not the AABBs are exactly equal.
Returns if the AABBs are not equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left AABB.
The right AABB.
Whether or not the AABBs are not equal.
Returns if the AABB is exactly equal
to the given object ().
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The object to compare with.
Whether or not the AABB and the object are equal.
Returns if the AABBs are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The other AABB.
Whether or not the AABBs are exactly equal.
Returns if this AABB and are approximately equal,
by running on each component.
The other AABB to compare.
Whether or not the AABBs structures are approximately equal.
Serves as the hash function for .
A hash code for this AABB.
Converts this to a string.
A string representation of this AABB.
Converts this to a string with the given .
A string representation of this AABB.
Wrapper around Godot's Array class, an array of Variant
typed elements allocated in the engine in C++. Useful when
interfacing with the engine. Otherwise prefer .NET collections
such as or .
Constructs a new empty .
Constructs a new from the given collection's elements.
The collection of elements to construct from.
A new Godot Array.
Constructs a new from the given objects.
The objects to put in the new array.
A new Godot Array.
Duplicates this .
If , performs a deep copy.
A new Godot Array.
Resizes this to the given size.
The new size of the array.
if successful, or an error code.
Shuffles the contents of this into a random order.
Concatenates these two s.
The first array.
The second array.
A new Godot Array with the contents of both arrays.
Disposes of this .
Returns the object at the given .
The object at the given .
Adds an object to the end of this .
This is the same as append or push_back in GDScript.
The object to add.
The new size after adding the object.
Checks if this contains the given object.
The item to look for.
Whether or not this array contains the given object.
Erases all items from this .
Searches this for an object
and returns its index or -1 if not found.
The object to search for.
The index of the object, or -1 if not found.
Inserts a new object at a given position in the array.
The position must be a valid position of an existing item,
or the position at the end of the array.
Existing items will be moved to the right.
The index to insert at.
The object to insert.
Removes the first occurrence of the specified
from this .
The value to remove.
Removes an element from this by index.
The index of the element to remove.
Returns the number of elements in this .
This is also known as the size or length of the array.
The number of elements.
Copies the elements of this to the given
untyped C# array, starting at the given index.
The array to copy to.
The index to start at.
Gets an enumerator for this .
An enumerator.
Converts this to a string.
A string representation of this array.
Typed wrapper around Godot's Array class, an array of Variant
typed elements allocated in the engine in C++. Useful when
interfacing with the engine. Otherwise prefer .NET collections
such as arrays or .
The type of the array.
Constructs a new empty .
Constructs a new from the given collection's elements.
The collection of elements to construct from.
A new Godot Array.
Constructs a new from the given items.
The items to put in the new array.
A new Godot Array.
Constructs a typed from an untyped .
The untyped array to construct from.
Converts this typed to an untyped .
The typed array to convert.
Duplicates this .
If , performs a deep copy.
A new Godot Array.
Resizes this to the given size.
The new size of the array.
if successful, or an error code.
Shuffles the contents of this into a random order.
Concatenates these two s.
The first array.
The second array.
A new Godot Array with the contents of both arrays.
Returns the value at the given .
The value at the given .
Searches this for an item
and returns its index or -1 if not found.
The item to search for.
The index of the item, or -1 if not found.
Inserts a new item at a given position in the .
The position must be a valid position of an existing item,
or the position at the end of the array.
Existing items will be moved to the right.
The index to insert at.
The item to insert.
Removes an element from this by index.
The index of the element to remove.
Returns the number of elements in this .
This is also known as the size or length of the array.
The number of elements.
Adds an item to the end of this .
This is the same as append or push_back in GDScript.
The item to add.
The new size after adding the item.
Erases all items from this .
Checks if this contains the given item.
The item to look for.
Whether or not this array contains the given item.
Copies the elements of this to the given
C# array, starting at the given index.
The C# array to copy to.
The index to start at.
Removes the first occurrence of the specified value
from this .
The value to remove.
A indicating success or failure.
Gets an enumerator for this .
An enumerator.
Converts this to a string.
A string representation of this array.
Wrapper around Godot's Dictionary class, a dictionary of Variant
typed elements allocated in the engine in C++. Useful when
interfacing with the engine.
Constructs a new empty .
Constructs a new from the given dictionary's elements.
The dictionary to construct from.
A new Godot Dictionary.
Disposes of this .
Duplicates this .
If , performs a deep copy.
A new Godot Dictionary.
Gets the collection of keys in this .
Gets the collection of elements in this .
Returns the object at the given .
The object at the given .
Adds an object at key
to this .
The key at which to add the object.
The object to add.
Erases all items from this .
Checks if this contains the given key.
The key to look for.
Whether or not this dictionary contains the given key.
Gets an enumerator for this .
An enumerator.
Removes an element from this by key.
The key of the element to remove.
Returns the number of elements in this .
This is also known as the size or length of the dictionary.
The number of elements.
Copies the elements of this to the given
untyped C# array, starting at the given index.
The array to copy to.
The index to start at.
Converts this to a string.
A string representation of this dictionary.
Typed wrapper around Godot's Dictionary class, a dictionary of Variant
typed elements allocated in the engine in C++. Useful when
interfacing with the engine. Otherwise prefer .NET collections
such as .
The type of the dictionary's keys.
The type of the dictionary's values.
Constructs a new empty .
Constructs a new from the given dictionary's elements.
The dictionary to construct from.
A new Godot Dictionary.
Constructs a new from the given dictionary's elements.
The dictionary to construct from.
A new Godot Dictionary.
Converts this typed to an untyped .
The typed dictionary to convert.
Duplicates this .
If , performs a deep copy.
A new Godot Dictionary.
Returns the value at the given .
The value at the given .
Gets the collection of keys in this .
Gets the collection of elements in this .
Adds an object at key
to this .
The key at which to add the object.
The object to add.
Checks if this contains the given key.
The key to look for.
Whether or not this dictionary contains the given key.
Removes an element from this by key.
The key of the element to remove.
Gets the object at the given .
The key of the element to get.
The value at the given .
If an object was found for the given .
Returns the number of elements in this .
This is also known as the size or length of the dictionary.
The number of elements.
Erases all the items from this .
Copies the elements of this to the given
untyped C# array, starting at the given index.
The array to copy to.
The index to start at.
Gets an enumerator for this .
An enumerator.
Converts this to a string.
A string representation of this dictionary.
3×3 matrix used for 3D rotation and scale.
Almost always used as an orthogonal basis for a Transform.
Contains 3 vector fields X, Y and Z as its columns, which are typically
interpreted as the local basis vectors of a 3D transformation. For such use,
it is composed of a scaling and a rotation matrix, in that order (M = R.S).
Can also be accessed as array of 3D vectors. These vectors are normally
orthogonal to each other, but are not necessarily normalized (due to scaling).
For more information, read this documentation article:
https://docs.godotengine.org/en/3.5/tutorials/math/matrices_and_transforms.html
The basis matrix's X vector (column 0).
Equivalent to and array index [0].
The basis matrix's Y vector (column 1).
Equivalent to and array index [1].
The basis matrix's Z vector (column 2).
Equivalent to and array index [2].
Row 0 of the basis matrix. Shows which vectors contribute
to the X direction. Rows are not very useful for user code,
but are more efficient for some internal calculations.
Row 1 of the basis matrix. Shows which vectors contribute
to the Y direction. Rows are not very useful for user code,
but are more efficient for some internal calculations.
Row 2 of the basis matrix. Shows which vectors contribute
to the Z direction. Rows are not very useful for user code,
but are more efficient for some internal calculations.
Column 0 of the basis matrix (the X vector).
Equivalent to and array index [0].
Column 1 of the basis matrix (the Y vector).
Equivalent to and array index [1].
Column 2 of the basis matrix (the Z vector).
Equivalent to and array index [2].
The scale of this basis.
Equivalent to the lengths of each column vector, but negative if the determinant is negative.
Access whole columns in the form of .
Which column vector.
The basis column.
Access matrix elements in column-major order.
Which column, the matrix horizontal position.
Which row, the matrix vertical position.
The matrix element.
Returns the 's rotation in the form of a
. See if you
need Euler angles, but keep in mind quaternions should generally
be preferred to Euler angles.
The basis rotation.
Returns the determinant of the basis matrix. If the basis is
uniformly scaled, its determinant is the square of the scale.
A negative determinant means the basis has a negative scale.
A zero determinant means the basis isn't invertible,
and is usually considered invalid.
The determinant of the basis matrix.
Returns the basis's rotation in the form of Euler angles
(in the YXZ convention: when *decomposing*, first Z, then X, and Y last).
The returned vector contains the rotation angles in
the format (X angle, Y angle, Z angle).
Consider using the method instead, which
returns a quaternion instead of Euler angles.
A representing the basis rotation in Euler angles.
Get rows by index. Rows are not very useful for user code,
but are more efficient for some internal calculations.
Which row.
Thrown when the is not 0, 1 or 2.
One of Row0, Row1, or Row2.
Sets rows by index. Rows are not very useful for user code,
but are more efficient for some internal calculations.
Which row.
The vector to set the row to.
Thrown when the is not 0, 1 or 2.
Deprecated, please use the array operator instead.
Which column.
One of `Column0`, `Column1`, or `Column2`.
Deprecated, please use the array operator instead.
Which column.
The vector to set the column to.
Deprecated, please use the array operator instead.
Which column.
One of `Column0`, `Column1`, or `Column2`.
This function considers a discretization of rotations into
24 points on unit sphere, lying along the vectors (x, y, z) with
each component being either -1, 0, or 1, and returns the index
of the point best representing the orientation of the object.
It is mainly used by the editor.
For further details, refer to the Godot source code.
The orthogonal index.
Returns the inverse of the matrix.
The inverse matrix.
Returns the orthonormalized version of the basis matrix (useful to
call occasionally to avoid rounding errors for orthogonal matrices).
This performs a Gram-Schmidt orthonormalization on the basis of the matrix.
An orthonormalized basis matrix.
Introduce an additional rotation around the given
by (in radians). The axis must be a normalized vector.
The axis to rotate around. Must be normalized.
The angle to rotate, in radians.
The rotated basis matrix.
Introduce an additional scaling specified by the given 3D scaling factor.
The scale to introduce.
The scaled basis matrix.
Assuming that the matrix is a proper rotation matrix, slerp performs
a spherical-linear interpolation with another rotation matrix.
The destination basis for interpolation.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting basis matrix of the interpolation.
Transposed dot product with the X axis of the matrix.
A vector to calculate the dot product with.
The resulting dot product.
Transposed dot product with the Y axis of the matrix.
A vector to calculate the dot product with.
The resulting dot product.
Transposed dot product with the Z axis of the matrix.
A vector to calculate the dot product with.
The resulting dot product.
Returns the transposed version of the basis matrix.
The transposed basis matrix.
Returns a vector transformed (multiplied) by the basis matrix.
A vector to transform.
The transformed vector.
Returns a vector transformed (multiplied) by the transposed basis matrix.
Note: This results in a multiplication by the inverse of the
basis matrix only if it represents a rotation-reflection.
A vector to inversely transform.
The inversely transformed vector.
Returns the basis's rotation in the form of a quaternion.
See if you need Euler angles, but keep in
mind that quaternions should generally be preferred to Euler angles.
A representing the basis's rotation.
The identity basis, with no rotation or scaling applied.
This is used as a replacement for Basis() in GDScript.
Do not use new Basis() with no arguments in C#, because it sets all values to zero.
Equivalent to new Basis(Vector3.Right, Vector3.Up, Vector3.Back).
The basis that will flip something along the X axis when used in a transformation.
Equivalent to new Basis(Vector3.Left, Vector3.Up, Vector3.Back).
The basis that will flip something along the Y axis when used in a transformation.
Equivalent to new Basis(Vector3.Right, Vector3.Down, Vector3.Back).
The basis that will flip something along the Z axis when used in a transformation.
Equivalent to new Basis(Vector3.Right, Vector3.Up, Vector3.Forward).
Constructs a pure rotation basis matrix from the given quaternion.
The quaternion to create the basis from.
Constructs a pure rotation basis matrix from the given Euler angles
(in the YXZ convention: when *composing*, first Y, then X, and Z last),
given in the vector format as (X angle, Y angle, Z angle).
Consider using the constructor instead, which
uses a quaternion instead of Euler angles.
The Euler angles to create the basis from.
Constructs a pure rotation basis matrix, rotated around the given
by (in radians). The axis must be a normalized vector.
The axis to rotate around. Must be normalized.
The angle to rotate, in radians.
Constructs a basis matrix from 3 axis vectors (matrix columns).
The X vector, or Column0.
The Y vector, or Column1.
The Z vector, or Column2.
Composes these two basis matrices by multiplying them
together. This has the effect of transforming the second basis
(the child) by the first basis (the parent).
The parent basis.
The child basis.
The composed basis.
Returns if the basis matrices are exactly
equal. Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left basis.
The right basis.
Whether or not the basis matrices are exactly equal.
Returns if the basis matrices are not equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left basis.
The right basis.
Whether or not the basis matrices are not equal.
Returns if the is
exactly equal to the given object ().
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The object to compare with.
Whether or not the basis matrix and the object are exactly equal.
Returns if the basis matrices are exactly
equal. Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The other basis.
Whether or not the basis matrices are exactly equal.
Returns if this basis and are approximately equal,
by running on each component.
The other basis to compare.
Whether or not the bases are approximately equal.
Serves as the hash function for .
A hash code for this basis.
Converts this to a string.
A string representation of this basis.
Converts this to a string with the given .
A string representation of this basis.
A color represented by red, green, blue, and alpha (RGBA) components.
The alpha component is often used for transparency.
Values are in floating-point and usually range from 0 to 1.
Some properties (such as ) may accept values
greater than 1 (overbright or HDR colors).
If you want to supply values in a range of 0 to 255, you should use
and the r8/g8/b8/a8 properties.
The color's red component, typically on the range of 0 to 1.
The color's green component, typically on the range of 0 to 1.
The color's blue component, typically on the range of 0 to 1.
The color's alpha (transparency) component, typically on the range of 0 to 1.
Wrapper for that uses the range 0 to 255 instead of 0 to 1.
Getting is equivalent to multiplying by 255 and rounding. Setting is equivalent to dividing by 255.
Wrapper for that uses the range 0 to 255 instead of 0 to 1.
Getting is equivalent to multiplying by 255 and rounding. Setting is equivalent to dividing by 255.
Wrapper for that uses the range 0 to 255 instead of 0 to 1.
Getting is equivalent to multiplying by 255 and rounding. Setting is equivalent to dividing by 255.
Wrapper for that uses the range 0 to 255 instead of 0 to 1.
Getting is equivalent to multiplying by 255 and rounding. Setting is equivalent to dividing by 255.
The HSV hue of this color, on the range 0 to 1.
Getting is a long process, refer to the source code for details. Setting uses .
The HSV saturation of this color, on the range 0 to 1.
Getting is equivalent to the ratio between the min and max RGB value. Setting uses .
The HSV value (brightness) of this color, on the range 0 to 1.
Getting is equivalent to using on the RGB components. Setting uses .
Returns a color according to the standardized name, with the
specified alpha value. Supported color names are the same as
the constants defined in .
The name of the color.
The alpha (transparency) component represented on the range of 0 to 1. Default: 1.
The constructed color.
Access color components using their index.
[0] is equivalent to ,
[1] is equivalent to ,
[2] is equivalent to ,
[3] is equivalent to .
Converts a color to HSV values. This is equivalent to using each of
the h/s/v properties, but much more efficient.
Output parameter for the HSV hue.
Output parameter for the HSV saturation.
Output parameter for the HSV value.
Constructs a color from an HSV profile, with values on the
range of 0 to 1. This is equivalent to using each of
the h/s/v properties, but much more efficient.
The HSV hue, typically on the range of 0 to 1.
The HSV saturation, typically on the range of 0 to 1.
The HSV value (brightness), typically on the range of 0 to 1.
The alpha (transparency) value, typically on the range of 0 to 1.
The constructed color.
Returns a new color resulting from blending this color over another.
If the color is opaque, the result is also opaque.
The second color may have a range of alpha values.
The color to blend over.
This color blended over .
Returns the most contrasting color.
The most contrasting color
Returns a new color resulting from making this color darker
by the specified ratio (on the range of 0 to 1).
The ratio to darken by.
The darkened color.
Returns the inverted color: (1 - r, 1 - g, 1 - b, a).
The inverted color.
Returns a new color resulting from making this color lighter
by the specified ratio (on the range of 0 to 1).
The ratio to lighten by.
The darkened color.
Returns the result of the linear interpolation between
this color and by amount .
The destination color for interpolation.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting color of the interpolation.
Returns the result of the linear interpolation between
this color and by color amount .
The destination color for interpolation.
A color with components on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting color of the interpolation.
Returns the color converted to a 32-bit integer in ABGR
format (each byte represents a color channel).
ABGR is the reversed version of the default format.
A representing this color in ABGR32 format.
Returns the color converted to a 64-bit integer in ABGR
format (each word represents a color channel).
ABGR is the reversed version of the default format.
A representing this color in ABGR64 format.
Returns the color converted to a 32-bit integer in ARGB
format (each byte represents a color channel).
ARGB is more compatible with DirectX, but not used much in Godot.
A representing this color in ARGB32 format.
Returns the color converted to a 64-bit integer in ARGB
format (each word represents a color channel).
ARGB is more compatible with DirectX, but not used much in Godot.
A representing this color in ARGB64 format.
Returns the color converted to a 32-bit integer in RGBA
format (each byte represents a color channel).
RGBA is Godot's default and recommended format.
A representing this color in RGBA32 format.
Returns the color converted to a 64-bit integer in RGBA
format (each word represents a color channel).
RGBA is Godot's default and recommended format.
A representing this color in RGBA64 format.
Returns the color's HTML hexadecimal color string in RGBA format.
Whether or not to include alpha. If , the color is RGB instead of RGBA.
A string for the HTML hexadecimal representation of this color.
Constructs a from RGBA values, typically on the range of 0 to 1.
The color's red component, typically on the range of 0 to 1.
The color's green component, typically on the range of 0 to 1.
The color's blue component, typically on the range of 0 to 1.
The color's alpha (transparency) value, typically on the range of 0 to 1. Default: 1.
Constructs a from an existing color and an alpha value.
The color to construct from. Only its RGB values are used.
The color's alpha (transparency) value, typically on the range of 0 to 1. Default: 1.
Constructs a from a 32-bit integer in RGBA format
(each byte represents a color channel).
The representing the color.
Constructs a from a 64-bit integer in RGBA format
(each word represents a color channel).
The representing the color.
Returns a color constructed from integer red, green, blue, and alpha channels.
Each channel should have 8 bits of information ranging from 0 to 255.
The red component represented on the range of 0 to 255.
The green component represented on the range of 0 to 255.
The blue component represented on the range of 0 to 255.
The alpha (transparency) component represented on the range of 0 to 255.
The constructed color.
Constructs a from the HTML hexadecimal color string in RGBA format.
A string for the HTML hexadecimal representation of this color.
Thrown when the given color code is invalid.
Adds each component of the
with the components of the given .
The left color.
The right color.
The added color.
Subtracts each component of the
by the components of the given .
The left color.
The right color.
The subtracted color.
Inverts the given color. This is equivalent to
Colors.White - c or
new Color(1 - c.r, 1 - c.g, 1 - c.b, 1 - c.a).
The color to invert.
The inverted color
Multiplies each component of the
by the given .
The color to multiply.
The value to multiply by.
The multiplied color.
Multiplies each component of the
by the given .
The value to multiply by.
The color to multiply.
The multiplied color.
Multiplies each component of the
by the components of the given .
The left color.
The right color.
The multiplied color.
Divides each component of the
by the given .
The dividend vector.
The divisor value.
The divided color.
Divides each component of the
by the components of the given .
The dividend color.
The divisor color.
The divided color.
Returns if the colors are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left color.
The right color.
Whether or not the colors are equal.
Returns if the colors are not equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left color.
The right color.
Whether or not the colors are equal.
Compares two s by first checking if
the red value of the color is less than
the red value of the color.
If the red values are exactly equal, then it repeats this check
with the green values of the two colors, then with the blue values,
and then with the alpha value.
This operator is useful for sorting colors.
The left color.
The right color.
Whether or not the left is less than the right.
Compares two s by first checking if
the red value of the color is greater than
the red value of the color.
If the red values are exactly equal, then it repeats this check
with the green values of the two colors, then with the blue values,
and then with the alpha value.
This operator is useful for sorting colors.
The left color.
The right color.
Whether or not the left is greater than the right.
Compares two s by first checking if
the red value of the color is less than
or equal to the red value of the color.
If the red values are exactly equal, then it repeats this check
with the green values of the two colors, then with the blue values,
and then with the alpha value.
This operator is useful for sorting colors.
The left color.
The right color.
Whether or not the left is less than or equal to the right.
Compares two s by first checking if
the red value of the color is greater than
or equal to the red value of the color.
If the red values are exactly equal, then it repeats this check
with the green values of the two colors, then with the blue values,
and then with the alpha value.
This operator is useful for sorting colors.
The left color.
The right color.
Whether or not the left is greater than or equal to the right.
Returns if this color and are equal.
The other object to compare.
Whether or not the color and the other object are equal.
Returns if the colors are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The other color.
Whether or not the colors are equal.
Returns if this color and are approximately equal,
by running on each component.
The other color to compare.
Whether or not the colors are approximately equal.
Serves as the hash function for .
A hash code for this color.
Converts this to a string.
A string representation of this color.
Converts this to a string with the given .
A string representation of this color.
This class contains color constants created from standardized color names.
The standardized color set is based on the X11 and .NET color names.
Represents an whose members can be dynamically accessed at runtime through the Variant API.
The class enables access to the Variant
members of a instance at runtime.
This allows accessing the class members using their original names in the engine as well as the members from the
script attached to the , regardless of the scripting language it was written in.
This sample shows how to use to dynamically access the engine members of a .
dynamic sprite = GetNode("Sprite").DynamicGodotObject;
sprite.add_child(this);
if ((sprite.hframes * sprite.vframes) > 0)
sprite.frame = 0;
This sample shows how to use to dynamically access the members of the script attached to a .
dynamic childNode = GetNode("ChildNode").DynamicGodotObject;
if (childNode.print_allowed)
{
childNode.message = "Hello from C#";
childNode.print_message(3);
}
The ChildNode node has the following GDScript script attached:
// # ChildNode.gd
// var print_allowed = true
// var message = ""
//
// func print_message(times):
// for i in times:
// print(message)
Gets the associated with this .
Initializes a new instance of the class.
The that will be associated with this .
Thrown when the parameter is .
Nodes are Godot's building blocks. They can be assigned as the child of another node, resulting in a tree arrangement. A given node can contain any number of nodes as children with the requirement that all siblings (direct children of a node) should have unique names.
A tree of nodes is called a scene. Scenes can be saved to the disk and then instanced into other scenes. This allows for very high flexibility in the architecture and data model of Godot projects.
Scene tree: The contains the active tree of nodes. When a node is added to the scene tree, it receives the notification and its callback is triggered. Child nodes are always added after their parent node, i.e. the callback of a parent node will be triggered before its child's.
Once all nodes have been added in the scene tree, they receive the notification and their respective callbacks are triggered. For groups of nodes, the callback is called in reverse order, starting with the children and moving up to the parent nodes.
This means that when adding a node to the scene tree, the following order will be used for the callbacks: of the parent, of the children, of the children and finally of the parent (recursively for the entire scene tree).
Processing: Nodes can override the "process" state, so that they receive a callback on each frame requesting them to process (do something). Normal processing (callback , toggled with ) happens as fast as possible and is dependent on the frame rate, so the processing time delta (in seconds) is passed as an argument. Physics processing (callback , toggled with ) happens a fixed number of times per second (60 by default) and is useful for code related to the physics engine.
Nodes can also process input events. When present, the function will be called for each input that the program receives. In many cases, this can be overkill (unless used for simple projects), and the function might be preferred; it is called when the input event was not handled by anyone else (typically, GUI nodes), ensuring that the node only receives the events that were meant for it.
To keep track of the scene hierarchy (especially when instancing scenes into other scenes), an "owner" can be set for the node with the property. This keeps track of who instanced what. This is mostly useful when writing editors and tools, though.
Finally, when a node is freed with or , it will also free all its children.
Groups: Nodes can be added to as many groups as you want to be easy to manage, you could create groups like "enemies" or "collectables" for example, depending on your game. See , and . You can then retrieve all nodes in these groups, iterate them and even call methods on groups via the methods on .
Networking with nodes: After connecting to a server (or making one, see ), it is possible to use the built-in RPC (remote procedure call) system to communicate over the network. By calling with a method name, it will be called locally and in all connected peers (peers = clients and the server that accepts connections). To identify which node receives the RPC call, Godot will use its (make sure node names are the same on all peers). Also, take a look at the high-level networking tutorial and corresponding demos.
Fetches a node. The can be either a relative path (from
the current node) or an absolute path (in the scene tree) to a node. If the path
does not exist, a instance is returned and an error
is logged. Attempts to access methods on the return value will result in an
"Attempt to call <method> on a null instance." error.
Note: Fetching absolute paths only works when the node is inside the scene tree
(see ).
Example: Assume your current node is Character and the following tree:
/root
/root/Character
/root/Character/Sword
/root/Character/Backpack/Dagger
/root/MyGame
/root/Swamp/Alligator
/root/Swamp/Mosquito
/root/Swamp/Goblin
Possible paths are:
GetNode("Sword");
GetNode("Backpack/Dagger");
GetNode("../Swamp/Alligator");
GetNode("/root/MyGame");
The path to the node to fetch.
Thrown when the given the fetched node can't be casted to the given type .
The type to cast to. Should be a descendant of .
The at the given .
Fetches a node. The can be either a relative path (from
the current node) or an absolute path (in the scene tree) to a node. If the path
does not exist, a instance is returned and an error
is logged. Attempts to access methods on the return value will result in an
"Attempt to call <method> on a null instance." error.
Note: Fetching absolute paths only works when the node is inside the scene tree
(see ).
Example: Assume your current node is Character and the following tree:
/root
/root/Character
/root/Character/Sword
/root/Character/Backpack/Dagger
/root/MyGame
/root/Swamp/Alligator
/root/Swamp/Mosquito
/root/Swamp/Goblin
Possible paths are:
GetNode("Sword");
GetNode("Backpack/Dagger");
GetNode("../Swamp/Alligator");
GetNode("/root/MyGame");
The path to the node to fetch.
The type to cast to. Should be a descendant of .
The at the given , or if not found.
Returns a child node by its index (see ).
This method is often used for iterating all children of a node.
Negative indices access the children from the last one.
To access a child node via its name, use .
Child index.
Thrown when the given the fetched node can't be casted to the given type .
The type to cast to. Should be a descendant of .
The child at the given index .
Returns a child node by its index (see ).
This method is often used for iterating all children of a node.
Negative indices access the children from the last one.
To access a child node via its name, use .
Child index.
The type to cast to. Should be a descendant of .
The child at the given index , or if not found.
The node owner. A node can have any other node as owner (as long as it is
a valid parent, grandparent, etc. ascending in the tree). When saving a
node (using ), all the nodes it owns will be saved
with it. This allows for the creation of complex s,
with instancing and subinstancing.
Thrown when the given the fetched node can't be casted to the given type .
The type to cast to. Should be a descendant of .
The owner .
The node owner. A node can have any other node as owner (as long as it is
a valid parent, grandparent, etc. ascending in the tree). When saving a
node (using ), all the nodes it owns will be saved
with it. This allows for the creation of complex s,
with instancing and subinstancing.
The type to cast to. Should be a descendant of .
The owner , or if there is no owner.
Returns the parent node of the current node, or a instance
if the node lacks a parent.
Thrown when the given the fetched node can't be casted to the given type .
The type to cast to. Should be a descendant of .
The parent .
Returns the parent node of the current node, or a instance
if the node lacks a parent.
The type to cast to. Should be a descendant of .
The parent , or if the node has no parent.
Notification received when the node enters a .
This notification is emitted before the related tree_entered.
Notification received when the node is about to exit a .
This notification is emitted after the related tree_exiting.
Notification received when the node is moved in the parent.
Notification received when the node is ready. See .
Notification received when the node is paused.
Notification received when the node is unpaused.
Notification received every frame when the physics process flag is set (see ).
Notification received every frame when the process flag is set (see ).
Notification received when a node is set as a child of another node.
Note: This doesn't mean that a node entered the .
Notification received when a node is unparented (parent removed it from the list of children).
Notification received when the node is instanced.
Notification received when a drag operation begins. All nodes receive this notification, not only the dragged one.
Can be triggered either by dragging a that provides drag data (see ) or using .
Use to get the dragged data.
Notification received when a drag operation ends.
Use to check if the drag succeeded.
Notification received when the node's changed.
Notification received every frame when the internal process flag is set (see ).
Notification received every frame when the internal physics process flag is set (see ).
Notification received when the node is ready, just before is received. Unlike the latter, it's sent every time the node enters tree, instead of only once.
Notification received when is called on the node or parent nodes.
Notification received from the OS when the mouse enters the game window.
Implemented on desktop and web platforms.
Notification received from the OS when the mouse leaves the game window.
Implemented on desktop and web platforms.
Notification received from the OS when the game window is focused.
Implemented on all platforms.
Notification received from the OS when the game window is unfocused.
Implemented on all platforms.
Notification received from the OS when a quit request is sent (e.g. closing the window with a "Close" button or Alt+F4).
Implemented on desktop platforms.
Notification received from the OS when a go back request is sent (e.g. pressing the "Back" button on Android).
Specific to the Android platform.
Notification received from the OS when an unfocus request is sent (e.g. another OS window wants to take the focus).
No supported platforms currently send this notification.
Notification received from the OS when the application is exceeding its allocated memory.
Specific to the iOS platform.
Notification received when translations may have changed. Can be triggered by the user changing the locale. Can be used to respond to language changes, for example to change the UI strings on the fly. Useful when working with the built-in translation support, like .
Notification received from the OS when a request for "About" information is sent.
Specific to the macOS platform.
Notification received from Godot's crash handler when the engine is about to crash.
Implemented on desktop platforms if the crash handler is enabled.
Notification received from the OS when an update of the Input Method Engine occurs (e.g. change of IME cursor position or composition string).
Specific to the macOS platform.
Notification received from the OS when the app is resumed.
Specific to the Android platform.
Notification received from the OS when the app is paused.
Specific to the Android platform.
Inherits pause mode from the node's parent. For the root node, it is equivalent to . Default.
Stops processing when the is paused.
Continue to process regardless of the pause state.
Duplicate the node's signals.
Duplicate the node's groups.
Duplicate the node's scripts.
Duplicate using instancing.
An instance stays linked to the original so when the original changes, the instance changes too.
Inherits physics interpolation mode from the node's parent. For the root node, it is equivalent to . Default.
Turn off physics interpolation in this node and children set to .
Turn on physics interpolation in this node and children set to .
Pause mode. How the node will behave if the is paused.
Allows enabling or disabling physics interpolation per node, offering a finer grain of control than turning physics interpolation on and off globally.
Note: This can be especially useful for s, where custom interpolation can sometimes give superior results.
The name of the node. This name is unique among the siblings (other child nodes from the same parent). When set to an existing name, the node will be automatically renamed.
Note: Auto-generated names might include the @ character, which is reserved for unique names when using . When setting the name manually, any @ will be removed.
Sets this node's name as a unique name in its . This allows the node to be accessed as %Name instead of the full path, from any node within that scene.
If another node with the same owner already had that name declared as unique, that other node's name will no longer be set as having a unique name.
If a scene is instantiated from a file, its topmost node contains the absolute file path from which it was loaded in (e.g. res://levels/1.tscn). Otherwise, is set to an empty string.
The node owner. A node can have any other node as owner (as long as it is a valid parent, grandparent, etc. ascending in the tree). When saving a node (using ), all the nodes it owns will be saved with it. This allows for the creation of complex s, with instancing and subinstancing.
Note: If you want a child to be persisted to a , you must set in addition to calling . This is typically relevant for tool scripts and editor plugins. If is called without setting , the newly added will not be visible in the scene tree, though it will be visible in the 2D/3D view.
The instance associated with this node. Either the , or the default SceneTree one (if inside tree).
The override to the default . Set to null to use the default one.
The node's priority in the execution order of the enabled processing callbacks (i.e. , and their internal counterparts). Nodes whose process priority value is lower will have their processing callbacks executed first.
Called when the node enters the (e.g. upon instancing, scene changing, or after calling in a script). If the node has children, its callback will be called first, and then that of the children.
Corresponds to the notification in .
Called when the node is about to leave the (e.g. upon freeing, scene changing, or after calling in a script). If the node has children, its callback will be called last, after all its children have left the tree.
Corresponds to the notification in and signal tree_exiting. To get notified when the node has already left the active tree, connect to the tree_exited.
The string returned from this method is displayed as a warning in the Scene Dock if the script that overrides it is a tool script.
Returning an empty string produces no warning.
Call when the warning needs to be updated for this node.
Called when there is an input event. The input event propagates up through the node tree until a node consumes it.
It is only called if input processing is enabled, which is done automatically if this method is overridden, and can be toggled with .
To consume the input event and stop it propagating further to other nodes, can be called.
For gameplay input, and are usually a better fit as they allow the GUI to intercept the events first.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan).
Called during the physics processing step of the main loop. Physics processing means that the frame rate is synced to the physics, i.e. the delta variable should be constant. delta is in seconds.
It is only called if physics processing is enabled, which is done automatically if this method is overridden, and can be toggled with .
Corresponds to the notification in .
Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan).
Called during the processing step of the main loop. Processing happens at every frame and as fast as possible, so the delta time since the previous frame is not constant. delta is in seconds.
It is only called if processing is enabled, which is done automatically if this method is overridden, and can be toggled with .
Corresponds to the notification in .
Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan).
Called when the node is "ready", i.e. when both the node and its children have entered the scene tree. If the node has children, their callbacks get triggered first, and the parent node will receive the ready notification afterwards.
Corresponds to the notification in . See also the onready keyword for variables.
Usually used for initialization. For even earlier initialization, may be used. See also .
Note: may be called only once for each node. After removing a node from the scene tree and adding it again, _ready will not be called a second time. This can be bypassed by requesting another call with , which may be called anywhere before adding the node again.
Called when an hasn't been consumed by or any GUI item. The input event propagates up through the node tree until a node consumes it.
It is only called if unhandled input processing is enabled, which is done automatically if this method is overridden, and can be toggled with .
To consume the input event and stop it propagating further to other nodes, can be called.
For gameplay input, this and are usually a better fit than as they allow the GUI to intercept the events first.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan).
Called when an hasn't been consumed by or any GUI item. The input event propagates up through the node tree until a node consumes it.
It is only called if unhandled key input processing is enabled, which is done automatically if this method is overridden, and can be toggled with .
To consume the input event and stop it propagating further to other nodes, can be called.
For gameplay input, this and are usually a better fit than as they allow the GUI to intercept the events first.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan).
Adds child_node as a child. The child is placed below the given node in the list of children.
If legible_unique_name is true, the child node will have a human-readable name based on the name of the node being instanced instead of its type.
Adds a child node. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node.
If legible_unique_name is true, the child node will have a human-readable name based on the name of the node being instanced instead of its type.
Note: If the child node already has a parent, the function will fail. Use first to remove the node from its current parent. For example:
if child_node.get_parent():
child_node.get_parent().remove_child(child_node)
add_child(child_node)
Note: If you want a child to be persisted to a , you must set in addition to calling . This is typically relevant for tool scripts and editor plugins. If is called without setting , the newly added will not be visible in the scene tree, though it will be visible in the 2D/3D view.
Removes a child node. The node is NOT deleted and must be deleted manually.
Note: This function may set the of the removed Node (or its descendants) to be null, if that is no longer a parent or ancestor.
Returns the number of child nodes.
Returns an array of references to node's children.
Returns a child node by its index (see ). This method is often used for iterating all children of a node.
To access a child node via its name, use .
Returns true if the node that the points to exists.
Fetches a node. The can be either a relative path (from the current node) or an absolute path (in the scene tree) to a node. If the path does not exist, null is returned and an error is logged. Attempts to access methods on the return value will result in an "Attempt to call <method> on a null instance." error.
Note: Fetching absolute paths only works when the node is inside the scene tree (see ).
Example: Assume your current node is Character and the following tree:
/root
/root/Character
/root/Character/Sword
/root/Character/Backpack/Dagger
/root/MyGame
/root/Swamp/Alligator
/root/Swamp/Mosquito
/root/Swamp/Goblin
Possible paths are:
get_node("Sword")
get_node("Backpack/Dagger")
get_node("../Swamp/Alligator")
get_node("/root/MyGame")
Similar to , but does not log an error if path does not point to a valid .
Returns the parent node of the current node, or null if the node lacks a parent.
Finds a descendant of this node whose name matches mask as in String.match (i.e. case-sensitive, but "*" matches zero or more characters and "?" matches any single character except "."). Returns null if no matching is found.
Note: It does not match against the full path, just against individual node names.
If owned is true, this method only finds nodes whose owner is this node. This is especially important for scenes instantiated through a script, because those scenes don't have an owner.
Note: As this method walks through all the descendants of the node, it is the slowest way to get a reference to another node. Whenever possible, consider using instead. To avoid using too often, consider caching the node reference into a variable.
Finds the first parent of the current node whose name matches mask as in String.match (i.e. case-sensitive, but "*" matches zero or more characters and "?" matches any single character except ".").
Note: It does not match against the full path, just against individual node names.
Note: As this method walks upwards in the scene tree, it can be slow in large, deeply nested scene trees. Whenever possible, consider using instead. To avoid using too often, consider caching the node reference into a variable.
Returns true if the points to a valid node and its subname points to a valid resource, e.g. Area2D/CollisionShape2D:shape. Properties with a non- type (e.g. nodes or primitive math types) are not considered resources.
Fetches a node and one of its resources as specified by the 's subname (e.g. Area2D/CollisionShape2D:shape). If several nested resources are specified in the , the last one will be fetched.
The return value is an array of size 3: the first index points to the (or null if not found), the second index points to the (or null if not found), and the third index is the remaining , if any.
For example, assuming that Area2D/CollisionShape2D is a valid node and that its shape property has been assigned a resource, one could have this kind of output:
print(get_node_and_resource("Area2D/CollisionShape2D")) # [[CollisionShape2D:1161], Null, ]
print(get_node_and_resource("Area2D/CollisionShape2D:shape")) # [[CollisionShape2D:1161], [RectangleShape2D:1156], ]
print(get_node_and_resource("Area2D/CollisionShape2D:shape:extents")) # [[CollisionShape2D:1161], [RectangleShape2D:1156], :extents]
Returns true if this node is currently inside a .
Returns true if the given node is a direct or indirect child of the current node.
Returns true if the given node occurs later in the scene hierarchy than the current node.
Returns the absolute path of the current node. This only works if the current node is inside the scene tree (see ).
Returns the relative from this node to the specified node. Both nodes must be in the same scene or the function will fail.
Adds the node to a group. Groups are helpers to name and organize a subset of nodes, for example "enemies" or "collectables". A node can be in any number of groups. Nodes can be assigned a group at any time, but will not be added until they are inside the scene tree (see ). See notes in the description, and the group methods in .
The persistent option is used when packing node to and saving to file. Non-persistent groups aren't stored.
Note: For performance reasons, the order of node groups is not guaranteed. The order of node groups should not be relied upon as it can vary across project runs.
Removes a node from a group. See notes in the description, and the group methods in .
Returns true if this node is in the specified group. See notes in the description, and the group methods in .
Moves a child node to a different position (order) among the other children. Since calls, signals, etc are performed by tree order, changing the order of children nodes may be useful.
Returns an array listing the groups that the node is a member of.
Note: For performance reasons, the order of node groups is not guaranteed. The order of node groups should not be relied upon as it can vary across project runs.
Note: The engine uses some group names internally (all starting with an underscore). To avoid conflicts with internal groups, do not add custom groups whose name starts with an underscore. To exclude internal groups while looping over , use the following snippet:
# Stores the node's non-internal groups only (as an array of Strings).
var non_internal_groups = []
for group in get_groups():
if not group.begins_with("_"):
non_internal_groups.push_back(group)
Moves this node to the bottom of parent node's children hierarchy. This is often useful in GUIs ( nodes), because their order of drawing depends on their order in the tree. The top Node is drawn first, then any siblings below the top Node in the hierarchy are successively drawn on top of it. After using raise, a Control will be drawn on top of its siblings.
Removes a node and sets all its children as children of the parent node (if it exists). All event subscriptions that pass by the removed node will be unsubscribed.
Returns the node's index, i.e. its position among the siblings of its parent.
Prints the tree to stdout. Used mainly for debugging purposes. This version displays the path relative to the current node, and is good for copy/pasting into the function.
Example output:
TheGame
TheGame/Menu
TheGame/Menu/Label
TheGame/Menu/Camera2D
TheGame/SplashScreen
TheGame/SplashScreen/Camera2D
Similar to , this prints the tree to stdout. This version displays a more graphical representation similar to what is displayed in the scene inspector. It is useful for inspecting larger trees.
Example output:
┖╴TheGame
┠╴Menu
┃ ┠╴Label
┃ ┖╴Camera2D
┖╴SplashScreen
┖╴Camera2D
Notifies the current node and all its children recursively by calling on all of them.
Calls the given method (if present) with the arguments given in args on this node and recursively on all its children. If the parent_first argument is true, the method will be called on the current node first, then on all its children. If parent_first is false, the children will be called first.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Enables or disables physics (i.e. fixed framerate) processing. When a node is being processed, it will receive a at a fixed (usually 60 FPS, see to change) interval (and the callback will be called if exists). Enabled automatically if is overridden. Any calls to this before will be ignored.
Returns the time elapsed (in seconds) since the last physics-bound frame (see ). This is always a constant value in physics processing unless the frames per second is changed via .
Returns true if physics processing is enabled (see ).
Returns the time elapsed (in seconds) since the last process callback. This value may vary from frame to frame.
Enables or disables processing. When a node is being processed, it will receive a on every drawn frame (and the callback will be called if exists). Enabled automatically if is overridden. Any calls to this before will be ignored.
Returns true if processing is enabled (see ).
Enables or disables input processing. This is not required for GUI controls! Enabled automatically if is overridden. Any calls to this before will be ignored.
Returns true if the node is processing input (see ).
Enables unhandled input processing. This is not required for GUI controls! It enables the node to receive all input that was not previously handled (usually by a ). Enabled automatically if is overridden. Any calls to this before will be ignored.
Returns true if the node is processing unhandled input (see ).
Enables unhandled key input processing. Enabled automatically if is overridden. Any calls to this before will be ignored.
Returns true if the node is processing unhandled key input (see ).
Returns true if the node can process while the scene tree is paused (see ). Always returns true if the scene tree is not paused, and false if the node is not in the tree.
Prints all stray nodes (nodes outside the ). Used for debugging. Works only in debug builds.
Returns the node's order in the scene tree branch. For example, if called on the first child node the position is 0.
Sets the folded state of the node in the Scene dock.
Returns true if the node is folded (collapsed) in the Scene dock.
Enables or disabled internal processing for this node. Internal processing happens in isolation from the normal calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or processing is disabled for scripting (). Only useful for advanced uses to manipulate built-in nodes' behavior.
Warning: Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported.
Returns true if internal processing is enabled (see ).
Enables or disables internal physics for this node. Internal physics processing happens in isolation from the normal calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or physics processing is disabled for scripting (). Only useful for advanced uses to manipulate built-in nodes' behavior.
Warning: Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported.
Returns true if internal physics processing is enabled (see ).
Returns true if the physics interpolated flag is set for this Node (see ).
Note: Interpolation will only be active if both the flag is set and physics interpolation is enabled within the . This can be tested using .
Returns true if physics interpolation is enabled (see ) and enabled in the .
This is a convenience version of that also checks whether physics interpolation is enabled globally.
See and .
When physics interpolation is active, moving a node to a radically different transform (such as placement within a level) can result in a visible glitch as the object is rendered moving from the old to new position over the physics tick.
This glitch can be prevented by calling reset_physics_interpolation, which temporarily turns off interpolation until the physics tick is complete.
will be received by the node and all children recursively.
Note: This function should be called after moving the node, rather than before.
Returns the that contains this node.
Creates a new and binds it to this node. This is equivalent of doing:
get_tree().create_tween().bind_node(self)
Duplicates the node, returning a new node.
You can fine-tune the behavior using the flags (see ).
Note: It will not work properly if the node contains a script with constructor arguments (i.e. needs to supply arguments to method). In that case, the node will be duplicated without a script.
Replaces a node in a scene by the given one. Subscriptions that pass through this node will be lost.
Note: The given node will become the new parent of any child nodes that the replaced node had.
Note: The replaced node is not automatically freed, so you either need to keep it in a variable for later use or free it using .
Sets whether this is an instance load placeholder. See .
Returns true if this is an instance load placeholder. See .
Returns the node's .
Queues a node for deletion at the end of the current frame. When deleted, all of its child nodes will be deleted as well. This method ensures it's safe to delete the node, contrary to . Use to check whether a node will be deleted at the end of the frame.
Important: If you have a variable pointing to a node, it will not be assigned to null once the node is freed. Instead, it will point to a previously freed instance and you should validate it with @GDScript.is_instance_valid before attempting to call its methods or access its properties.
Requests that _ready be called again. Note that the method won't be called immediately, but is scheduled for when the node is added to the scene tree again (see ). _ready is called only for the node which requested it, which means that you need to request ready for each child if you want them to call _ready too (in which case, _ready will be called in the same order as it would normally).
Sets the node's network master to the peer with the given peer ID. The network master is the peer that has authority over the node on the network. Useful in conjunction with the master and puppet keywords. Inherited from the parent node by default, which ultimately defaults to peer ID 1 (the server). If recursive, the given peer is recursively set as the master for all children of this node.
Returns the peer ID of the network master for this node. See .
Returns true if the local system is the master of this node.
Changes the RPC mode for the given method to the given mode. See . An alternative is annotating methods and properties with the corresponding keywords (remote, master, puppet, remotesync, mastersync, puppetsync). By default, methods are not exposed to networking (and RPCs). See also and for properties.
Changes the RPC mode for the given property to the given mode. See . An alternative is annotating methods and properties with the corresponding keywords (remote, master, puppet, remotesync, mastersync, puppetsync). By default, properties are not exposed to networking (and RPCs). See also and for methods.
Sends a remote procedure call request for the given method to peers on the network (and locally), optionally sending all additional arguments as arguments to the method called by the RPC. The call request will only be received by nodes with the same , including the exact same node name. Behaviour depends on the RPC configuration for the given method, see . Methods are not exposed to RPCs by default. See also and for properties. Returns null.
Note: You can only safely use RPCs on clients after you received the connected_to_server signal from the . You also need to keep track of the connection state, either by the signals like server_disconnected or by checking SceneTree.network_peer.get_connection_status() == CONNECTION_CONNECTED.
Sends a using an unreliable protocol. Returns null.
Sends a to a specific peer identified by peer_id (see ). Returns null.
Sends a to a specific peer identified by peer_id using an unreliable protocol (see ). Returns null.
Remotely changes a property's value on other peers (and locally). Behaviour depends on the RPC configuration for the given property, see . See also for RPCs for methods, most information applies to this method as well.
Remotely changes the property's value on a specific peer identified by peer_id (see ).
Remotely changes the property's value on other peers (and locally) using an unreliable protocol.
Remotely changes property's value on a specific peer identified by peer_id using an unreliable protocol (see ).
Updates the warning displayed for this node in the Scene Dock.
Use to setup the warning message to display.
Every class which is not a built-in type inherits from this class.
You can construct Objects from scripting languages, using Object.new() in GDScript, new Object in C#, or the "Construct Object" node in VisualScript.
Objects do not manage memory. If a class inherits from Object, you will have to delete instances of it manually. To do so, call the method from your script or delete the instance from C++.
Some classes that extend Object add memory management. This is the case of , which counts references and deletes itself automatically when no longer referenced. , another fundamental type, deletes all its children when freed from memory.
Objects export properties, which are mainly useful for storage and editing, but not really so much in programming. Properties are exported in and handled in and . However, scripting languages and C++ have simpler means to export them.
Property membership can be tested directly in GDScript using in:
var n = Node2D.new()
print("position" in n) # Prints "True".
print("other_property" in n) # Prints "False".
The in operator will evaluate to true as long as the key exists, even if the value is null.
Objects also receive notifications. Notifications are a simple way to notify the object about different events, so they can all be handled together. See .
Note: Unlike references to a , references to an Object stored in a variable can become invalid without warning. Therefore, it's recommended to use for data classes instead of .
Note: Due to a bug, you can't create a "plain" Object using Object.new(). Instead, use ClassDB.instance("Object"). This bug only applies to Object itself, not any of its descendents like .
Returns whether is a valid object
(e.g. has not been deleted from memory).
The instance to check.
If the instance is a valid object.
Returns a weak reference to an object, or
if the argument 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.
The object.
The reference to the object or .
Constructs a new .
The pointer to the native instance of this .
Disposes of this .
Disposes implementation of this .
Converts this to a string.
A string representation of this object.
Returns a new awaiter configured to complete when the instance
emits the signal specified by the parameter.
The instance the awaiter will be listening to.
The signal the awaiter will be waiting for.
This sample prints a message once every frame up to 100 times.
public override void _Ready()
{
for (int i = 0; i < 100; i++)
{
await ToSignal(GetTree(), "idle_frame");
GD.Print($"Frame {i}");
}
}
A that completes when
emits the .
Gets a new associated with this instance.
Called right when the object is initialized. Not available in script.
Called before the object is about to be deleted.
Connects a signal in deferred mode. This way, signal emissions are stored in a queue, then set on idle time.
Persisting connections are saved when the object is serialized to file.
One-shot connections disconnect themselves after emission.
Connect a signal as reference-counted. This means that a given signal can be connected several times to the same target, and will only be fully disconnected once no references are left.
Virtual method which can be overridden to customize the return value of .
Returns the given property. Returns null if the property does not exist.
Virtual method which can be overridden to customize the return value of .
Returns the object's property list as an of dictionaries.
Each property's must contain at least name: String and type: int (see ) entries. Optionally, it can also include hint: int (see ), hint_string: String, and usage: int (see ).
Called whenever the object receives a notification, which is identified in what by a constant. The base has two constants and , but subclasses such as define a lot more notifications which are also received by this method.
Virtual method which can be overridden to customize the return value of .
Sets a property. Returns true if the property exists.
Deletes the object from memory immediately. For s, you may want to use to queue the node for safe deletion at the end of the current frame.
Important: If you have a variable pointing to an object, it will not be assigned to null once the object is freed. Instead, it will point to a previously freed instance and you should validate it with @GDScript.is_instance_valid before attempting to call its methods or access its properties.
Returns the object's class as a . See also .
Note: does not take class_name declarations into account. If the object has a class_name defined, the base class name will be returned instead.
Returns true if the object inherits from the given class. See also .
Note: does not take class_name declarations into account. If the object has a class_name defined, will return false for that name.
Assigns a new value to the given property. If the property does not exist or the given value's type doesn't match, nothing will happen.
Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).
Returns the Variant value of the given property. If the property doesn't exist, this will return null.
Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).
Assigns a new value to the property identified by the . The node path should be relative to the current object and can use the colon character (:) to access nested properties. Example:
set_indexed("position", Vector2(42, 0))
set_indexed("position:y", -10)
print(position) # (42, -10)
Gets the object's property indexed by the given . The node path should be relative to the current object and can use the colon character (:) to access nested properties. Examples: "position:x" or "material:next_pass:blend_mode".
Note: Even though the method takes argument, it doesn't support actual paths to s in the scene tree, only colon-separated sub-property paths. For the purpose of nodes, use instead.
Returns the object's property list as an of dictionaries.
Each property's contain at least name: String and type: int (see ) entries. Optionally, it can also include hint: int (see ), hint_string: String, and usage: int (see ).
Returns the object's methods and their signatures as an .
Send a given notification to the object, which will also trigger a call to the method of all classes that the object inherits from.
If reversed is true, is called first on the object's own class, and then up to its successive parent classes. If reversed is false, is called first on the highest ancestor ( itself), and then down to its successive inheriting classes.
Returns the object's unique instance ID.
This ID can be saved in , and can be used to retrieve the object instance with @GDScript.instance_from_id.
Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality.
If the object already had a script, the previous script instance will be freed and its variables and state will be lost. The new script's method will be called.
Returns the object's instance, or null if none is assigned.
Adds, changes or removes a given entry in the object's metadata. Metadata are serialized and can take any Variant value.
To remove a given entry from the object's metadata, use . Metadata is also removed if its value is set to null. This means you can also use set_meta("name", null) to remove metadata for "name".
Removes a given entry from the object's metadata. See also .
Returns the object's metadata entry for the given name.
Throws error if the entry does not exist, unless default is not null (in which case the default value will be returned).
Returns true if a metadata entry is found with the given name.
Returns the object's metadata as a .
Adds a user-defined signal. Arguments are optional, but can be added as an of dictionaries, each containing name: String and type: int (see ) entries.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Returns true if the given user-defined signal exists. Only signals added using are taken into account.
Emits the given signal. The signal must exist, so it should be a built-in signal of this class or one of its parent classes, or a user-defined signal. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:
emit_signal("hit", weapon_type, damage)
emit_signal("game_over")
Calls the method on the object and returns the result. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:
call("set", "position", Vector2(42.0, 0.0))
Note: In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase).
Calls the method on the object during idle time. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:
call_deferred("set", "position", Vector2(42.0, 0.0))
Note: In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase).
Assigns a new value to the given property, after the current frame's physics step. This is equivalent to calling via , i.e. call_deferred("set", property, value).
Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).
Calls the method on the object and returns the result. Contrarily to , this method does not support a variable number of arguments but expects all parameters to be via a single .
callv("set", [ "position", Vector2(42.0, 0.0) ])
Returns true if the object contains the given method.
Returns true if the given signal exists.
Returns the list of signals as an of dictionaries.
Returns an of connections for the given signal.
Returns an of dictionaries with information about signals that are connected to the object.
Each contains three String entries:
- source is a reference to the signal emitter.
- signal_name is the name of the connected signal.
- method_name is the name of the method to which the signal is connected.
Connects a signal to a method on a target object. Pass optional binds to the call as an of parameters. These parameters will be passed to the method after any parameter used in the call to . Use flags to set deferred or one-shot connections. See constants.
A signal can only be connected once to a method. It will print an error if already connected, unless the signal was connected with . To avoid this, first, use to check for existing connections.
If the target is destroyed in the game's lifecycle, the connection will be lost.
Examples:
connect("pressed", self, "_on_Button_pressed") # BaseButton signal
connect("text_entered", self, "_on_LineEdit_text_entered") # LineEdit signal
connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # User-defined signal
An example of the relationship between binds passed to and parameters used when calling :
connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # weapon_type and damage are passed last
emit_signal("hit", "Dark lord", 5) # "Dark lord" and 5 are passed first
func _on_Player_hit(hit_by, level, weapon_type, damage):
print("Hit by %s (lvl %d) with weapon %s for %d damage" % [hit_by, level, weapon_type, damage])
If the parameter is null, then the default value is new Godot.Collections.Array { }
Disconnects a signal from a method on the given target.
If you try to disconnect a connection that does not exist, the method will print an error. Use to ensure that the connection exists.
Returns true if a connection exists for a given signal, target, and method.
If set to true, signal emission is blocked.
Returns true if signal emission blocking is enabled.
Notify the editor that the property list has changed, so that editor plugins can take the new values into account. Does nothing on export builds.
Defines whether the object can translate strings (with calls to ). Enabled by default.
Returns true if the object can translate strings. See and .
Translates a message using translation catalogs configured in the Project Settings.
Only works if message translation is enabled (which it is by default), otherwise it returns the message unchanged. See .
Returns true if the method was called for the object.
A simplified interface to a scene file. Provides access to operations and checks that can be performed on the scene resource itself.
Can be used to save a node to a file. When saving, the node as well as all the nodes it owns get saved (see owner property on ).
Note: The node doesn't need to own itself.
Example of loading a saved scene:
# Use `load()` instead of `preload()` if the path isn't known at compile-time.
var scene = preload("res://scene.tscn").instance()
# Add the node as a child of the node the script is attached to.
add_child(scene)
Example of saving a node with different owners: The following example creates 3 objects: Node2D (node), RigidBody2D (rigid) and CollisionObject2D (collision). collision is a child of rigid which is a child of node. Only rigid is owned by node and pack will therefore only save those two nodes, but not collision.
# Create the objects.
var node = Node2D.new()
var rigid = RigidBody2D.new()
var collision = CollisionShape2D.new()
# Create the object hierarchy.
rigid.add_child(collision)
node.add_child(rigid)
# Change owner of `rigid`, but not of `collision`.
rigid.owner = node
var scene = PackedScene.new()
# Only `node` and `rigid` are now packed.
var result = scene.pack(node)
if result == OK:
var error = ResourceSaver.save("res://path/name.scn", scene) # Or "user://..."
if error != OK:
push_error("An error occurred while saving the scene to disk.")
Instantiates the scene's node hierarchy, erroring on failure.
Triggers child scene instantiation(s). Triggers a
notification on the root node.
Thrown when the given the instantiated node can't be casted to the given type .
The type to cast to. Should be a descendant of .
The instantiated scene.
Instantiates the scene's node hierarchy, returning on failure.
Triggers child scene instantiation(s). Triggers a
notification on the root node.
The type to cast to. Should be a descendant of .
The instantiated scene.
If passed to , blocks edits to the scene state.
If passed to , provides local scene resources to the local scene.
Note: Only available in editor builds.
If passed to , provides local scene resources to the local scene. Only the main scene should receive the main edit state.
Note: Only available in editor builds.
It's similar to , but for the case where the scene is being instantiated to be the base of another one.
Note: Only available in editor builds.
A dictionary representation of the scene contents.
Available keys include "rnames" and "variants" for resources, "node_count", "nodes", "node_paths" for nodes, "editable_instances" for base scene children overrides, "conn_count" and "conns" for signal connections, and "version" for the format style of the PackedScene.
Pack will ignore any sub-nodes not owned by given node. See .
Instantiates the scene's node hierarchy. Triggers child scene instantiation(s). Triggers a notification on the root node.
Returns true if the scene file has nodes.
Returns the SceneState representing the scene file contents.
Singleton used to load resource files from the filesystem.
It uses the many classes registered in the engine (either built-in or from a plugin) to load files into memory and convert them to a format that can be used by the engine.
Loads a resource at the given , caching the result
for further access.
The registered instances are queried sequentially
to find the first one which can handle the file's extension, and then attempt
loading. If loading fails, the remaining ResourceFormatLoaders are also attempted.
An optional can be used to further specify the
type that should be handled by the .
Anything that inherits from can be used as a type hint,
for example .
If is , the resource cache will be bypassed and
the resource will be loaded anew. Otherwise, the cached resource will be returned if it exists.
Returns an empty resource if no could handle the file.
Thrown when the given the loaded resource can't be casted to the given type .
The type to cast to. Should be a descendant of .
Starts loading a resource interactively. The returned object allows to load with high granularity, calling its method successively to load chunks.
An optional type_hint can be used to further specify the type that should be handled by the . Anything that inherits from can be used as a type hint, for example .
Loads a resource at the given path, caching the result for further access.
The registered s are queried sequentially to find the first one which can handle the file's extension, and then attempt loading. If loading fails, the remaining ResourceFormatLoaders are also attempted.
An optional type_hint can be used to further specify the type that should be handled by the . Anything that inherits from can be used as a type hint, for example .
If no_cache is true, the resource cache will be bypassed and the resource will be loaded anew. Otherwise, the cached resource will be returned if it exists.
Returns an empty resource if no could handle the file.
GDScript has a simplified @GDScript.load built-in method which can be used in most situations, leaving the use of for more advanced scenarios.
Returns the list of recognized extensions for a resource type.
Changes the behavior on missing sub-resources. The default behavior is to abort loading.
Returns the dependencies for the resource at the given path.
Returns whether a cached resource is available for the given path.
Once a resource has been loaded by the engine, it is cached in memory for faster access, and future calls to the or methods will use the cached version. The cached resource can be overridden by using on a new resource for that same path.
Returns whether a recognized resource exists for the given path.
An optional type_hint can be used to further specify the type that should be handled by the .
Deprecated method. Use or instead.
Godot's global functions.
Decodes a byte array back to a Variant value.
If is decoding objects is allowed.
WARNING: Deserialized object can contain code which gets executed.
Do not set to
if the serialized object comes from untrusted sources to avoid
potential security threats (remote code execution).
Byte array that will be decoded to a Variant.
If objects should be decoded.
The decoded Variant.
Converts from a Variant type to another in the best way possible.
The parameter uses the values.
var a = new Vector2(1, 0);
// Prints 1
GD.Print(a.Length());
var b = GD.Convert(a, Variant.Type.String)
// Prints 6 as "(1, 0)" is 6 characters
GD.Print(b.Length);
The Variant converted to the given .
Converts from decibels to linear energy (audio).
Decibels to convert.
Audio volume as linear energy.
Returns the result of decreased by
* .
// a = 59;
// float a = GD.DecTime(60, 10, 0.1f);
Value that will be decreased.
Amount that will be decreased from for every .
Times the will be decreased by
The decreased value.
Get the that refers to the function
with the given name in the
given object .
The object that contains the function.
The name of the function.
A reference to the given object's function.
Returns the integer hash of the variable passed.
GD.Print(GD.Hash("a")); // Prints 177670
Variable that will be hashed.
Hash of the variable passed.
Returns the that corresponds to .
All Objects have a unique instance ID.
public class MyNode : Node
{
public string foo = "bar";
public override void _Ready()
{
ulong id = GetInstanceId();
var inst = (MyNode)GD.InstanceFromId(Id);
GD.Print(inst.foo); // Prints bar
}
}
Instance ID of the Object to retrieve.
The instance.
Converts from linear energy to decibels (audio).
This can be used to implement volume sliders that behave as expected (since volume isn't linear).
// "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.SetBusVolumeDb(AudioServer.GetBusIndex("Master"), GD.Linear2Db(slider.value));
The linear energy to convert.
Audio as decibels.
Loads a resource from the filesystem located at .
The resource is loaded on the method call (unless it's referenced already
elsewhere, e.g. in another script or in the scene), which might cause slight delay,
especially when loading scenes. To avoid unnecessary delays when loading something
multiple times, either store the resource in a variable.
Note: Resource paths can be obtained by right-clicking on a resource in the FileSystem
dock and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script.
Important: The path must be absolute, a local path will just return .
This method is a simplified version of , which can be used
for more advanced scenarios.
// Load a scene called main located in the root of the project directory and cache it in a variable.
var main = GD.Load("res://main.tscn"); // main will contain a PackedScene resource.
Path of the to load.
The loaded .
Loads a resource from the filesystem located at .
The resource is loaded on the method call (unless it's referenced already
elsewhere, e.g. in another script or in the scene), which might cause slight delay,
especially when loading scenes. To avoid unnecessary delays when loading something
multiple times, either store the resource in a variable.
Note: Resource paths can be obtained by right-clicking on a resource in the FileSystem
dock and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script.
Important: The path must be absolute, a local path will just return .
This method is a simplified version of , which can be used
for more advanced scenarios.
// Load a scene called main located in the root of the project directory and cache it in a variable.
var main = GD.Load<PackedScene>("res://main.tscn"); // main will contain a PackedScene resource.
Path of the to load.
The type to cast to. Should be a descendant of .
Pushes an error message to Godot's built-in debugger and to the OS terminal.
Note: Errors printed this way will not pause project execution.
To print an error message and pause project execution in debug builds,
use [code]assert(false, "test error")[/code] instead.
GD.PushError("test_error"); // Prints "test error" to debugger and terminal as error call
Error message.
Pushes a warning message to Godot's built-in debugger and to the OS terminal.
GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as warning call
Warning message.
Converts one or more arguments of any type to string in the best way possible
and prints them to the console.
Note: Consider using and
to print error and warning messages instead of .
This distinguishes them from print messages used for debugging purposes,
while also displaying a stack trace when an error or warning is printed.
var a = new int[] { 1, 2, 3 };
GD.Print("a", "b", a); // Prints ab[1, 2, 3]
Arguments that will be printed.
Prints the current stack trace information to the console.
Prints one or more arguments to strings in the best way possible to standard error line.
GD.PrintErr("prints to stderr");
Arguments that will be printed.
Prints one or more arguments to strings in the best way possible to console.
No newline is added at the end.
Note: Due to limitations with Godot's built-in console, this only prints to the terminal.
If you need to print in the editor, use another method, such as .
GD.PrintRaw("A");
GD.PrintRaw("B");
// Prints AB
Arguments that will be printed.
Prints one or more arguments to the console with a space between each argument.
GD.PrintS("A", "B", "C"); // Prints A B C
Arguments that will be printed.
Prints one or more arguments to the console with a tab between each argument.
GD.PrintT("A", "B", "C"); // Prints A B C
Arguments that will be printed.
Returns a random floating point value between 0.0 and 1.0 (inclusive).
GD.Randf(); // Returns e.g. 0.375671
A random number.
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).
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
A random number.
Randomizes the seed (or the internal state) of the random number generator.
Current implementation reseeds using a number based on time.
Note: This method is called automatically when the project is run.
If you need to fix the seed to have reproducible results, use
to initialize the random number generator.
Returns a random floating point value on the interval between
and (inclusive).
GD.PrintS(GD.RandRange(-10.0, 10.0), GD.RandRange(-10.0, 10.0)); // Prints e.g. -3.844535 7.45315
A random number inside the given range.
Returns a random unsigned 32-bit integer, using the given .
The will return the new seed.
Seed to use to generate the random number.
Seed used by the random number generator.
A random number.
Returns a that iterates from
0 to in steps of 1.
The last index.
Returns a that iterates from
to in steps of 1.
The first index.
The last index.
Returns a that iterates from
to in steps of .
The first index.
The last index.
The amount by which to increment the index on each iteration.
Sets seed for the random number generator.
Seed that will be used.
Converts one or more arguments of any type to string in the best way possible.
Arguments that will converted to string.
The string formed by the given arguments.
Converts a formatted string that was returned by to the original value.
string a = "{\"a\": 1, \"b\": 2 }";
var b = (Godot.Collections.Dictionary)GD.Str2Var(a);
GD.Print(b["a"]); // Prints 1
String that will be converted to Variant.
The decoded Variant.
Returns whether the given class exists in .
If the class exists in .
Encodes a Variant value to a byte array.
If is encoding objects is allowed
(and can potentially include code).
Deserialization can be done with .
Variant that will be encoded.
If objects should be serialized.
The Variant encoded as an array of bytes.
Converts a Variant to a formatted string that
can later be parsed using .
var a = new Godot.Collections.Dictionary { ["a"] = 1, ["b"] = 2 };
GD.Print(GD.Var2Str(a));
// Prints
// {
// "a": 1,
// "b": 2
// }
Variant that will be converted to string.
The Variant encoded as a string.
Fires when an unhandled exception occurs, regardless of project settings.
Scancodes with this bit applied are non-printable.
Returns if the generic type definition of
is ; otherwise returns .
Thrown when the given is not a generic type.
That is, returns .
Returns if the generic type definition of
is ; otherwise returns .
Thrown when the given is not a generic type.
That is, returns .
Returns if the generic type definition of
is ; otherwise returns .
Thrown when the given is not a generic type.
That is, returns .
Returns if the generic type definition of
is ; otherwise returns .
Thrown when the given is not a generic type.
That is, returns .
Returns if the generic type definition of
is ; otherwise returns .
Thrown when the given is not a generic type.
That is, returns .
Returns if the generic type definition of
is ; otherwise returns .
Thrown when the given is not a generic type.
That is, returns .
Returns if the generic type definition of
is ; otherwise returns .
Thrown when the given is not a generic type.
That is, returns .
Returns the generic type definition of .
Thrown when the given is not a generic type.
That is, returns .
Gets the element type for the given .
Type for the generic array.
Element type for the generic array.
Thrown when the given is not a generic type.
That is, returns .
Gets the key type and the value type for the given .
The type for the generic dictionary.
Key type for the generic dictionary.
Value type for the generic dictionary.
Thrown when the given is not a generic type.
That is, returns .
Constructs a new from
where the generic type for the elements is .
Element type for the array.
The generic array type with the specified element type.
Constructs a new from
where the generic type for the keys is and
for the values is .
Key type for the dictionary.
Key type for the dictionary.
The generic dictionary type with the specified key and value types.
Provides constants and static methods for common mathematical functions.
The circle constant, the circumference of the unit circle in radians.
Constant that represents how many times the diameter of a circle
fits around its perimeter. This is equivalent to Mathf.Tau / 2.
Positive infinity. For negative infinity, use -Mathf.Inf.
"Not a Number", an invalid value. NaN has special properties, including
that it is not equal to itself. It is output by some invalid operations,
such as dividing zero by zero.
Returns the absolute value of (i.e. positive value).
The input number.
The absolute value of .
Returns the absolute value of (i.e. positive value).
The input number.
The absolute value of .
Returns the arc cosine of in radians.
Use to get the angle of cosine .
The input cosine value. Must be on the range of -1.0 to 1.0.
An angle that would result in the given cosine value. On the range 0 to Tau/2.
Returns the arc sine of in radians.
Use to get the angle of sine .
The input sine value. Must be on the range of -1.0 to 1.0.
An angle that would result in the given sine value. On the range -Tau/4 to Tau/4.
Returns the arc tangent of in radians.
Use to get the angle of tangent .
The method cannot know in which quadrant the angle should fall.
See if you have both y and x.
The input tangent value.
An angle that would result in the given tangent value. On the range -Tau/4 to Tau/4.
Returns the arc tangent of and in radians.
Use to get the angle of the tangent of 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.
The Y coordinate of the point to find the angle to.
The X coordinate of the point to find the angle to.
An angle that would result in the given tangent value. On the range -Tau/2 to Tau/2.
Converts a 2D point expressed in the cartesian coordinate
system (X and Y axis) to the polar coordinate system
(a distance from the origin and an angle).
The input X coordinate.
The input Y coordinate.
A with X representing the distance and Y representing the angle.
Rounds upward (towards positive infinity).
The number to ceil.
The smallest whole number that is not less than .
Clamps a so that it is not less than
and not more than .
The value to clamp.
The minimum allowed value.
The maximum allowed value.
The clamped value.
Clamps a so that it is not less than
and not more than .
The value to clamp.
The minimum allowed value.
The maximum allowed value.
The clamped value.
Returns the cosine of angle in radians.
The angle in radians.
The cosine of that angle.
Returns the hyperbolic cosine of angle in radians.
The angle in radians.
The hyperbolic cosine of that angle.
Converts an angle expressed in degrees to radians.
An angle expressed in degrees.
The same angle expressed in radians.
Easing function, based on exponent. The values are:
0 is constant, 1 is linear, 0 to 1 is ease-in, 1 or more is ease-out.
Negative values are in-out/out-in.
The value to ease.
0 is constant, 1 is linear, 0 to 1 is ease-in, 1 or more is ease-out.
The eased value.
The natural exponential function. It raises the mathematical
constant e to the power of and returns it.
The exponent to raise e to.
e raised to the power of .
Rounds downward (towards negative infinity).
The number to floor.
The largest whole number that is not more than .
Returns a normalized value considering the given range.
This is the opposite of .
The start value for interpolation.
The destination value for interpolation.
The interpolated value.
The resulting value of the inverse interpolation.
The returned value will be between 0.0 and 1.0 if is
between and (inclusive).
Returns if and are approximately equal
to each other.
The comparison is done using a tolerance calculation with .
One of the values.
The other value.
A for whether or not the two values are approximately equal.
Returns whether is an infinity value (either positive infinity or negative infinity).
The value to check.
A for whether or not the value is an infinity value.
Returns whether is a NaN ("Not a Number" or invalid) value.
The value to check.
A for whether or not the value is a NaN value.
Returns if is approximately zero.
The comparison is done using a tolerance calculation with .
This method is faster than using with one value as zero.
The value to check.
A for whether or not the value is nearly zero.
Linearly interpolates between two values by a normalized value.
This is the opposite .
The start value for interpolation.
The destination value for interpolation.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting value of the interpolation.
Linearly interpolates between two angles (in radians) by a normalized value.
Similar to ,
but interpolates correctly when the angles wrap around .
The start angle for interpolation.
The destination angle for interpolation.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting angle of the interpolation.
Natural logarithm. 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.
The input value.
The natural log of .
Returns the maximum of two values.
One of the values.
The other value.
Whichever of the two values is higher.
Returns the maximum of two values.
One of the values.
The other value.
Whichever of the two values is higher.
Returns the minimum of two values.
One of the values.
The other value.
Whichever of the two values is lower.
Returns the minimum of two values.
One of the values.
The other value.
Whichever of the two values is lower.
Moves toward by the value.
Use a negative value to move away.
The start value.
The value to move towards.
The amount to move by.
The value after moving.
Returns the nearest larger power of 2 for the integer .
The input value.
The nearest larger power of 2.
Converts a 2D point expressed in the polar coordinate
system (a distance from the origin
and an angle ) to the cartesian
coordinate system (X and Y axis).
The distance from the origin.
The angle of the point.
A representing the cartesian coordinate.
Performs a canonical Modulus operation, where the output is on the range [0, ).
The dividend, the primary input.
The divisor. The output is on the range [0, ).
The resulting output.
Performs a canonical Modulus operation, where the output is on the range [0, ).
The dividend, the primary input.
The divisor. The output is on the range [0, ).
The resulting output.
Returns the result of raised to the power of .
The base.
The exponent.
raised to the power of .
Converts an angle expressed in radians to degrees.
An angle expressed in radians.
The same angle expressed in degrees.
Maps a from [, ]
to [, ].
The value to map.
The start value for the input interpolation.
The destination value for the input interpolation.
The start value for the output interpolation.
The destination value for the output interpolation.
The resulting mapped value mapped.
Rounds to the nearest whole number,
with halfway cases rounded towards the nearest multiple of two.
The number to round.
The rounded number.
Returns the sign of : -1 or 1.
Returns 0 if is 0.
The input number.
One of three possible values: 1, -1, or 0.
Returns the sign of : -1 or 1.
Returns 0 if is 0.
The input number.
One of three possible values: 1, -1, or 0.
Returns the sine of angle in radians.
The angle in radians.
The sine of that angle.
Returns the hyperbolic sine of angle in radians.
The angle in radians.
The hyperbolic sine of that angle.
Returns a number smoothly interpolated between and ,
based on the . Similar to ,
but interpolates faster at the beginning and slower at the end.
The start value for interpolation.
The destination value for interpolation.
A value representing the amount of interpolation.
The resulting value of the interpolation.
Returns the square root of , where is a non-negative number.
If you need negative inputs, use .
The input number. Must not be negative.
The square root of .
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.
The input value.
The position of the first non-zero digit.
Snaps float value to a given .
This can also be used to round a floating point number to an arbitrary number of decimals.
The value to stepify.
The step size to snap to.
The snapped value.
Returns the tangent of angle in radians.
The angle in radians.
The tangent of that angle.
Returns the hyperbolic tangent of angle in radians.
The angle in radians.
The hyperbolic tangent of that angle.
Wraps between and .
Usable for creating loop-alike behavior or infinite surfaces.
If is 0, this is equivalent
to , so prefer using that instead.
The value to wrap.
The minimum allowed value and lower bound of the range.
The maximum allowed value and upper bound of the range.
The wrapped value.
Wraps between and .
Usable for creating loop-alike behavior or infinite surfaces.
If is 0, this is equivalent
to , so prefer using that instead.
The value to wrap.
The minimum allowed value and lower bound of the range.
The maximum allowed value and upper bound of the range.
The wrapped value.
The natural number e.
The square root of 2.
A very small number used for float comparison with error tolerance.
1e-06 with single-precision floats, but 1e-14 if REAL_T_IS_DOUBLE.
Returns the amount of digits after the decimal place.
The input value.
The amount of digits.
Returns the amount of digits after the decimal place.
The input value.
The amount of digits.
Rounds upward (towards positive infinity).
This is the same as , but returns an .
The number to ceil.
The smallest whole number that is not less than .
Rounds downward (towards negative infinity).
This is the same as , but returns an .
The number to floor.
The largest whole number that is not more than .
Rounds to the nearest whole number.
This is the same as , but returns an .
The number to round.
The rounded number.
Returns if and are approximately
equal to each other.
The comparison is done using the provided tolerance value.
If you want the tolerance to be calculated for you, use .
One of the values.
The other value.
The pre-calculated tolerance value.
A for whether or not the two values are equal.
A pre-parsed relative or absolute path in a scene tree,
for use with and similar functions.
It can reference a node, a resource within a node, or a property
of a node or resource.
For instance, "Path2D/PathFollow2D/Sprite2D:texture:size"
would refer to the size property of the texture
resource on the node named "Sprite2D" which is a child of
the other named nodes in the path.
You will usually just pass a string to
and it will be automatically converted, but you may occasionally
want to parse a path ahead of time with NodePath.
Exporting a NodePath variable will give you a node selection widget
in the properties panel of the editor, which can often be useful.
A NodePath is composed of a list of slash-separated node names
(like a filesystem path) and an optional colon-separated list of
"subnames" which can be resources or properties.
Note: In the editor, NodePath properties are automatically updated when moving,
renaming or deleting a node in the scene tree, but they are never updated at runtime.
Some examples of NodePaths include the following:
// No leading slash means it is relative to the current node.
new NodePath("A"); // Immediate child A.
new NodePath("A/B"); // A's child B.
new NodePath("."); // The current node.
new NodePath(".."); // The parent node.
new NodePath("../C"); // A sibling node C.
// A leading slash means it is absolute from the SceneTree.
new NodePath("/root"); // Equivalent to GetTree().Root
new NodePath("/root/Main"); // If your main scene's root node were named "Main".
new NodePath("/root/MyAutoload"); // If you have an autoloaded node or scene.
Disposes of this .
The pointer to the native instance of this .
Constructs an empty .
Constructs a from a string ,
e.g.: "Path2D/PathFollow2D/Sprite2D:texture:size".
A path is absolute if it starts with a slash. Absolute paths
are only valid in the global scene tree, not within individual
scenes. In a relative path, "." and ".." indicate
the current node and its parent.
The "subnames" optionally included after the path to the target
node can point to resources or properties, and can also be nested.
Examples of valid NodePaths (assuming that those nodes exist and
have the referenced resources or properties):
// Points to the Sprite2D node.
"Path2D/PathFollow2D/Sprite2D"
// Points to the Sprite2D node and its "texture" resource.
// GetNode() would retrieve "Sprite2D", while GetNodeAndResource()
// would retrieve both the Sprite2D node and the "texture" resource.
"Path2D/PathFollow2D/Sprite2D:texture"
// Points to the Sprite2D node and its "position" property.
"Path2D/PathFollow2D/Sprite2D:position"
// Points to the Sprite2D node and the "x" component of its "position" property.
"Path2D/PathFollow2D/Sprite2D:position:x"
// Absolute path (from "root")
"/root/Level/Path2D"
A string that represents a path in a scene tree.
Converts a string to a .
The string to convert.
Converts this to a string.
The to convert.
Converts this to a string.
A string representation of this .
Returns a node path with a colon character (:) prepended,
transforming it to a pure property path with no node name (defaults
to resolving from the current node).
// This will be parsed as a node path to the "x" property in the "position" node.
var nodePath = new NodePath("position:x");
// This will be parsed as a node path to the "x" component of the "position" property in the current node.
NodePath propertyPath = nodePath.GetAsPropertyPath();
GD.Print(propertyPath); // :position:x
The as a pure property path.
Returns all subnames concatenated with a colon character (:)
as separator, i.e. the right side of the first colon in a node path.
var nodepath = new NodePath("Path2D/PathFollow2D/Sprite2D:texture:load_path");
GD.Print(nodepath.GetConcatenatedSubnames()); // texture:load_path
The subnames concatenated with :.
Gets the node name indicated by (0 to ).
var nodePath = new NodePath("Path2D/PathFollow2D/Sprite2D");
GD.Print(nodePath.GetName(0)); // Path2D
GD.Print(nodePath.GetName(1)); // PathFollow2D
GD.Print(nodePath.GetName(2)); // Sprite
The name index.
The name at the given index .
Gets the number of node names which make up the path.
Subnames (see ) are not included.
For example, "Path2D/PathFollow2D/Sprite2D" has 3 names.
The number of node names which make up the path.
Gets the resource or property name indicated by (0 to ).
The subname index.
The subname at the given index .
Gets the number of resource or property names ("subnames") in the path.
Each subname is listed after a colon character (:) in the node path.
For example, "Path2D/PathFollow2D/Sprite2D:texture:load_path" has 2 subnames.
The number of subnames in the path.
Returns if the node path is absolute (as opposed to relative),
which means that it starts with a slash character (/). Absolute node paths can
be used to access the root node ("/root") or autoloads (e.g. "/global"
if a "global" autoload was registered).
If the is an absolute path.
Returns if the node path is empty.
If the is empty.
Plane represents a normalized plane equation.
"Over" or "Above" the plane is considered the side of
the plane towards where the normal is pointing.
The normal of the plane, which must be normalized.
In the scalar equation of the plane ax + by + cz = d, this is
the vector (a, b, c), where d is the property.
Equivalent to , , and .
The X component of the plane's normal vector.
Equivalent to 's X value.
The Y component of the plane's normal vector.
Equivalent to 's Y value.
The Z component of the plane's normal vector.
Equivalent to 's Z value.
The distance from the origin to the plane (in the direction of
). This value is typically non-negative.
In the scalar equation of the plane ax + by + cz = d,
this is d, while the (a, b, c) coordinates are represented
by the property.
The plane's distance from the origin.
The center of the plane, the point where the normal line intersects the plane.
Equivalent to multiplied by .
Returns the shortest distance from this plane to the position .
The position to use for the calculation.
The shortest distance.
The center of the plane, the point where the normal line intersects the plane.
Deprecated, use the Center property instead.
Equivalent to multiplied by `D`.
Returns if point is inside the plane.
Comparison uses a custom minimum epsilon threshold.
The point to check.
The tolerance threshold.
A for whether or not the plane has the point.
Returns the intersection point of the three planes: , ,
and this plane. If no intersection is found, is returned.
One of the three planes to use in the calculation.
One of the three planes to use in the calculation.
The intersection, or if none is found.
Returns the intersection point of a ray consisting of the position
and the direction normal with this plane.
If no intersection is found, is returned.
The start of the ray.
The direction of the ray, normalized.
The intersection, or if none is found.
Returns the intersection point of a line segment from
position to position with this plane.
If no intersection is found, is returned.
The start of the line segment.
The end of the line segment.
The intersection, or if none is found.
Returns if is located above the plane.
The point to check.
A for whether or not the point is above the plane.
Returns the plane scaled to unit length.
A normalized version of the plane.
Returns the orthogonal projection of into the plane.
The point to project.
The projected point.
A that extends in the Y and Z axes (normal vector points +X).
Equivalent to new Plane(1, 0, 0, 0).
A that extends in the X and Z axes (normal vector points +Y).
Equivalent to new Plane(0, 1, 0, 0).
A that extends in the X and Y axes (normal vector points +Z).
Equivalent to new Plane(0, 0, 1, 0).
Constructs a from four values.
, and become the
components of the resulting plane's vector.
becomes the plane's distance from the origin.
The X component of the plane's normal vector.
The Y component of the plane's normal vector.
The Z component of the plane's normal vector.
The plane's distance from the origin. This value is typically non-negative.
Constructs a from a vector and
the plane's distance to the origin .
The normal of the plane, must be normalized.
The plane's distance from the origin. This value is typically non-negative.
Constructs a from the three points, given in clockwise order.
The first point.
The second point.
The third point.
Returns the negative value of the .
This is the same as writing new Plane(-p.Normal, -p.D).
This operation flips the direction of the normal vector and
also flips the distance value, resulting in a Plane that is
in the same place, but facing the opposite direction.
The plane to negate/flip.
The negated/flipped plane.
Returns if the
s are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left rect.
The right rect.
Whether or not the planes are exactly equal.
Returns if the
s are not equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left rect.
The right rect.
Whether or not the planes are not equal.
Returns if this plane and are equal.
The other object to compare.
Whether or not the plane and the other object are exactly equal.
Returns if this plane and are equal.
The other plane to compare.
Whether or not the planes are exactly equal.
Returns if this plane and are
approximately equal, by running on each component.
The other plane to compare.
Whether or not the planes are approximately equal.
Serves as the hash function for .
A hash code for this plane.
Converts this to a string.
A string representation of this plane.
Converts this to a string with the given .
A string representation of this plane.
A unit quaternion used for representing 3D rotations.
Quaternions need to be normalized to be used for rotation.
It is similar to , which implements matrix
representation of rotations, and can be parametrized using both
an axis-angle pair or Euler angles. Basis stores rotation, scale,
and shearing, while Quat only stores rotation.
Due to its compactness and the way it is stored in memory, certain
operations (obtaining axis-angle and performing SLERP, in particular)
are more efficient and robust against floating-point errors.
X component of the quaternion (imaginary i axis part).
Quaternion components should usually not be manipulated directly.
Y component of the quaternion (imaginary j axis part).
Quaternion components should usually not be manipulated directly.
Z component of the quaternion (imaginary k axis part).
Quaternion components should usually not be manipulated directly.
W component of the quaternion (real part).
Quaternion components should usually not be manipulated directly.
Access quaternion components using their index.
[0] is equivalent to ,
[1] is equivalent to ,
[2] is equivalent to ,
[3] is equivalent to .
Returns the length (magnitude) of the quaternion.
Equivalent to Mathf.Sqrt(LengthSquared).
Returns the squared length (squared magnitude) of the quaternion.
This method runs faster than , so prefer it if
you need to compare quaternions or need the squared length for some formula.
Equivalent to Dot(this).
Returns the angle between this quaternion and .
This is the magnitude of the angle you would need to rotate
by to get from one to the other.
Note: This method has an abnormally high amount
of floating-point error, so methods such as
will not work reliably.
The other quaternion.
The angle between the quaternions.
Performs a cubic spherical interpolation between quaternions , this quaternion,
, and , by the given amount .
The destination quaternion.
A quaternion before this quaternion.
A quaternion after .
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The interpolated quaternion.
Returns the dot product of two quaternions.
The other quaternion.
The dot product.
Returns Euler angles (in the YXZ convention: when decomposing,
first Z, then X, and Y last) corresponding to the rotation
represented by the unit quaternion. Returned vector contains
the rotation angles in the format (X angle, Y angle, Z angle).
The Euler angle representation of this quaternion.
Returns the inverse of the quaternion.
The inverse quaternion.
Returns whether the quaternion is normalized or not.
A for whether the quaternion is normalized or not.
Returns a copy of the quaternion, normalized to unit length.
The normalized quaternion.
Returns the result of the spherical linear interpolation between
this quaternion and by amount .
Note: Both quaternions must be normalized.
The destination quaternion for interpolation. Must be normalized.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting quaternion of the interpolation.
Returns the result of the spherical linear interpolation between
this quaternion and by amount , but without
checking if the rotation path is not bigger than 90 degrees.
The destination quaternion for interpolation. Must be normalized.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting quaternion of the interpolation.
Returns a vector transformed (multiplied) by this quaternion.
A vector to transform.
The transformed vector.
The identity quaternion, representing no rotation.
Equivalent to an identity matrix. If a vector is transformed by
an identity quaternion, it will not change.
Equivalent to new Quat(0, 0, 0, 1).
Constructs a defined by the given values.
X component of the quaternion (imaginary i axis part).
Y component of the quaternion (imaginary j axis part).
Z component of the quaternion (imaginary k axis part).
W component of the quaternion (real part).
Constructs a from the given .
The existing quaternion.
Constructs a from the given .
The to construct from.
Constructs a that will perform a rotation specified by
Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last),
given in the vector format as (X angle, Y angle, Z angle).
Euler angles that the quaternion will be rotated by.
Constructs a that will rotate around the given axis
by the specified angle. The axis must be a normalized vector.
The axis to rotate around. Must be normalized.
The angle to rotate, in radians.
Composes these two quaternions by multiplying them together.
This has the effect of rotating the second quaternion
(the child) by the first quaternion (the parent).
The parent quaternion.
The child quaternion.
The composed quaternion.
Adds each component of the left
to the right . This operation is not
meaningful on its own, but it can be used as a part of a
larger expression, such as approximating an intermediate
rotation between two nearby rotations.
The left quaternion to add.
The right quaternion to add.
The added quaternion.
Subtracts each component of the left
by the right . This operation is not
meaningful on its own, but it can be used as a part of a
larger expression.
The left quaternion to subtract.
The right quaternion to subtract.
The subtracted quaternion.
Returns the negative value of the .
This is the same as writing
new Quat(-q.x, -q.y, -q.z, -q.w). This operation
results in a quaternion that represents the same rotation.
The quaternion to negate.
The negated quaternion.
Multiplies each component of the
by the given . This operation is not
meaningful on its own, but it can be used as a part of a
larger expression.
The quaternion to multiply.
The value to multiply by.
The multiplied quaternion.
Multiplies each component of the
by the given . This operation is not
meaningful on its own, but it can be used as a part of a
larger expression.
The value to multiply by.
The quaternion to multiply.
The multiplied quaternion.
Divides each component of the
by the given . This operation is not
meaningful on its own, but it can be used as a part of a
larger expression.
The quaternion to divide.
The value to divide by.
The divided quaternion.
Returns if the quaternions are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left quaternion.
The right quaternion.
Whether or not the quaternions are exactly equal.
Returns if the quaternions are not equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left quaternion.
The right quaternion.
Whether or not the quaternions are not equal.
Returns if this quaternion and are equal.
The other object to compare.
Whether or not the quaternion and the other object are exactly equal.
Returns if this quaternion and are equal.
The other quaternion to compare.
Whether or not the quaternions are exactly equal.
Returns if this quaternion and are approximately equal,
by running on each component.
The other quaternion to compare.
Whether or not the quaternions are approximately equal.
Serves as the hash function for .
A hash code for this quaternion.
Converts this to a string.
A string representation of this quaternion.
Converts this to a string with the given .
A string representation of this quaternion.
2D axis-aligned bounding box. Rect2 consists of a position, a size, and
several utility functions. It is typically used for fast overlap tests.
Beginning corner. Typically has values lower than .
Directly uses a private field.
Size from to . Typically all components are positive.
If the size is negative, you can use to fix it.
Directly uses a private field.
Ending corner. This is calculated as plus .
Setting this value will change the size.
Getting is equivalent to = + ,
setting is equivalent to = -
The area of this .
Equivalent to .
Returns a with equivalent position and size, modified so that
the top-left corner is the origin and width and height are positive.
The modified .
Returns the intersection of this and .
If the rectangles do not intersect, an empty is returned.
The other .
The clipped .
Returns if this completely encloses another one.
The other that may be enclosed.
A for whether or not this encloses .
Returns this expanded to include a given point.
The point to include.
The expanded .
Returns the area of the .
The area.
Returns the center of the , which is equal
to + ( / 2).
The center.
Returns a copy of the grown a given amount of units towards
all the sides.
The amount to grow by.
The grown .
Returns a copy of the grown a given amount of units towards
each direction individually.
The amount to grow by on the left.
The amount to grow by on the top.
The amount to grow by on the right.
The amount to grow by on the bottom.
The grown .
Returns a copy of the grown a given amount of units towards
the direction.
The direction to grow in.
The amount to grow by.
The grown .
Returns if the is flat or empty,
or otherwise.
A for whether or not the has area.
Returns if the contains a point,
or otherwise.
The point to check.
A for whether or not the contains .
Returns if the overlaps with
(i.e. they have at least one point in common).
If is ,
they will also be considered overlapping if their borders touch,
even without intersection.
The other to check for intersections with.
Whether or not to consider borders.
A for whether or not they are intersecting.
Returns a larger that contains this and .
The other .
The merged .
Constructs a from a position and size.
The position.
The size.
Constructs a from a position, width, and height.
The position.
The width.
The height.
Constructs a from x, y, and size.
The position's X coordinate.
The position's Y coordinate.
The size.
Constructs a from x, y, width, and height.
The position's X coordinate.
The position's Y coordinate.
The width.
The height.
Returns if the
s are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left rect.
The right rect.
Whether or not the rects are exactly equal.
Returns if the
s are not equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left rect.
The right rect.
Whether or not the rects are not equal.
Returns if this rect and are equal.
The other object to compare.
Whether or not the rect and the other object are exactly equal.
Returns if this rect and are equal.
The other rect to compare.
Whether or not the rects are exactly equal.
Returns if this rect and are approximately equal,
by running on each component.
The other rect to compare.
Whether or not the rects are approximately equal.
Serves as the hash function for .
A hash code for this rect.
Converts this to a string.
A string representation of this rect.
Converts this to a string with the given .
A string representation of this rect.
The RID type is used to access the unique integer ID of a resource.
They are opaque, which means they do not grant access to the associated
resource by themselves. They are used by and with the low-level Server
classes such as .
Disposes of this .
The pointer to the native instance of this .
Constructs a new for the given .
Returns the ID of the referenced resource.
The ID of the referenced resource.
Converts this to a string.
A string representation of this RID.
Extension methods to manipulate strings.
If the string is a path to a file, return the path to the file without the extension.
The path to a file.
The path to the file without the extension.
Returns if the strings begins
with the given string .
The string to check.
The beginning string.
If the string begins with the given string.
Returns the bigrams (pairs of consecutive letters) of this string.
The string that will be used.
The bigrams of this string.
Converts a string containing a binary number into an integer.
Binary strings can either be prefixed with 0b or not,
and they can also start with a - before the optional prefix.
The string to convert.
The converted string.
Returns the amount of substrings in the string.
The string where the substring will be searched.
The substring that will be counted.
If the search is case sensitive.
Index to start searching from.
Index to stop searching at.
Amount of substrings in the string.
Returns a copy of the string with special characters escaped using the C language standard.
The string to escape.
The escaped string.
Returns a copy of the string with escaped characters replaced by their meanings
according to the C language standard.
The string to unescape.
The unescaped string.
Changes the case of some letters. Replace underscores with spaces, convert all letters
to lowercase then capitalize first and every letter following the space character.
For capitalize camelCase mixed_with_underscores it will return
Capitalize Camelcase Mixed With Underscores.
The string to capitalize.
The capitalized string.
Performs a case-sensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater.
The string to compare.
The other string to compare.
-1 if less, 0 if equal and +1 if greater.
Performs a comparison to another string, return -1 if less, 0 if equal and +1 if greater.
The string to compare.
The other string to compare.
If , the comparison will be case sensitive.
-1 if less, 0 if equal and +1 if greater.
Returns if the string is empty.
Returns if the strings ends
with the given string .
The string to check.
The ending string.
If the string ends with the given string.
Erase characters from the string starting from .
The string to modify.
Starting position from which to erase.
Amount of characters to erase.
Returns the extension without the leading period character (.)
if the string is a valid file name or path. If the string does not contain
an extension, returns an empty string instead.
GD.Print("/path/to/file.txt".GetExtension()) // "txt"
GD.Print("file.txt".GetExtension()) // "txt"
GD.Print("file.sample.txt".GetExtension()) // "txt"
GD.Print(".txt".GetExtension()) // "txt"
GD.Print("file.txt.".GetExtension()) // "" (empty string)
GD.Print("file.txt..".GetExtension()) // "" (empty string)
GD.Print("txt".GetExtension()) // "" (empty string)
GD.Print("".GetExtension()) // "" (empty string)
The path to a file.
The extension of the file or an empty string.
Find the first occurrence of a substring. Optionally, the search starting position can be passed.
The string that will be searched.
The substring to find.
The search starting position.
If , the search is case sensitive.
The starting position of the substring, or -1 if not found.
Find the first occurrence of a char. Optionally, the search starting position can be passed.
The string that will be searched.
The substring to find.
The search starting position.
If , the search is case sensitive.
The first instance of the char, or -1 if not found.
Find the last occurrence of a substring.
The string that will be searched.
The substring to find.
If , the search is case sensitive.
The starting position of the substring, or -1 if not found.
Find the last occurrence of a substring specifying the search starting position.
The string that will be searched.
The substring to find.
The search starting position.
If , the search is case sensitive.
The starting position of the substring, or -1 if not found.
Find the first occurrence of a substring but search as case-insensitive.
Optionally, the search starting position can be passed.
The string that will be searched.
The substring to find.
The search starting position.
The starting position of the substring, or -1 if not found.
If the string is a path to a file, return the base directory.
The path to a file.
The base directory.
If the string is a path to a file, return the file and ignore the base directory.
The path to a file.
The file name.
Converts the given byte array of ASCII encoded text to a string.
Faster alternative to if the
content is ASCII-only. Unlike the UTF-8 function this function
maps every byte to a character in the array. Multibyte sequences
will not be interpreted correctly. For parsing user input always
use .
A byte array of ASCII characters (on the range of 0-127).
A string created from the bytes.
Converts the given byte array of UTF-8 encoded text to a string.
Slower than but supports UTF-8
encoded data. Use this function if you are unsure about the
source of the data. For user input this function
should always be preferred.
A byte array of UTF-8 characters (a character may take up multiple bytes).
A string created from the bytes.
Hash the string and return a 32 bits unsigned integer.
The string to hash.
The calculated hash of the string.
Returns a hexadecimal representation of this byte as a string.
The byte to encode.
The hexadecimal representation of this byte.
Returns a hexadecimal representation of this byte array as a string.
The byte array to encode.
The hexadecimal representation of this byte array.
Converts a string containing a hexadecimal number into an integer.
Hexadecimal strings can either be prefixed with 0x or not,
and they can also start with a - before the optional prefix.
The string to convert.
The converted string.
Inserts a substring at a given position.
The string to modify.
Position at which to insert the substring.
Substring to insert.
The string with inserted at the given
position .
Returns if the string is a path to a file or
directory and its starting point is explicitly defined. This includes
res://, user://, C:\, /, etc.
The string to check.
If the string is an absolute path.
Returns if the string is a path to a file or
directory and its starting point is implicitly defined within the
context it is being used. The starting point may refer to the current
directory (./), or the current .
The string to check.
If the string is a relative path.
Check whether this string is a subsequence of the given string.
The subsequence to search.
The string that contains the subsequence.
If , the check is case sensitive.
If the string is a subsequence of the given string.
Check whether this string is a subsequence of the given string, ignoring case differences.
The subsequence to search.
The string that contains the subsequence.
If the string is a subsequence of the given string.
Check whether the string contains a valid .
The string to check.
If the string contains a valid floating point number.
Check whether the string contains a valid color in HTML notation.
The string to check.
If the string contains a valid HTML color.
Check whether the string is a valid identifier. As is common in
programming languages, a valid identifier may contain only letters,
digits and underscores (_) and the first character may not be a digit.
The string to check.
If the string contains a valid identifier.
Check whether the string contains a valid integer.
The string to check.
If the string contains a valid integer.
Check whether the string contains a valid IP address.
The string to check.
If the string contains a valid IP address.
Returns a copy of the string with special characters escaped using the JSON standard.
The string to escape.
The escaped string.
Returns an amount of characters from the left of the string.
The original string.
The position in the string where the left side ends.
The left side of the string from the given position.
Returns the length of the string in characters.
The string to check.
The length of the string.
Returns a copy of the string with characters removed from the left.
The string to remove characters from.
The characters to be removed.
A copy of the string with characters removed from the left.
Do a simple expression match, where '*' matches zero or more
arbitrary characters and '?' matches any single character except '.'.
The string to check.
Expression to check.
If , the check will be case sensitive.
If the expression has any matches.
Do a simple case sensitive expression match, using ? and * wildcards
(see ).
The string to check.
Expression to check.
If , the check will be case sensitive.
If the expression has any matches.
Do a simple case insensitive expression match, using ? and * wildcards
(see ).
The string to check.
Expression to check.
If the expression has any matches.
Returns the MD5 hash of the string as an array of bytes.
The string to hash.
The MD5 hash of the string.
Returns the MD5 hash of the string as a string.
The string to hash.
The MD5 hash of the string.
Perform a case-insensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater.
The string to compare.
The other string to compare.
-1 if less, 0 if equal and +1 if greater.
Returns the character code at position .
The string to check.
The position int the string for the character to check.
The character code.
Format a number to have an exact number of
after the decimal point.
The string to pad.
Amount of digits after the decimal point.
The string padded with zeroes.
Format a number to have an exact number of
before the decimal point.
The string to pad.
Amount of digits before the decimal point.
The string padded with zeroes.
Decode a percent-encoded string. See .
Percent-encode a string. This is meant to encode parameters in a URL
when sending a HTTP GET request and bodies of form-urlencoded POST request.
If the string is a path, this concatenates
at the end of the string as a subpath.
E.g. "this/is".PlusFile("path") == "this/is/path".
The path that will be concatenated.
File name to concatenate with the path.
The concatenated path with the given file name.
Replace occurrences of a substring for different ones inside the string.
The string to modify.
The substring to be replaced in the string.
The substring that replaces .
The string with the substring occurrences replaced.
Replace occurrences of a substring for different ones inside the string, but search case-insensitive.
The string to modify.
The substring to be replaced in the string.
The substring that replaces .
The string with the substring occurrences replaced.
Perform a search for a substring, but start from the end of the string instead of the beginning.
The string that will be searched.
The substring to search in the string.
The position at which to start searching.
The position at which the substring was found, or -1 if not found.
Perform a search for a substring, but start from the end of the string instead of the beginning.
Also search case-insensitive.
The string that will be searched.
The substring to search in the string.
The position at which to start searching.
The position at which the substring was found, or -1 if not found.
Returns the right side of the string from a given position.
The original string.
The position in the string from which the right side starts.
The right side of the string from the given position.
Returns a copy of the string with characters removed from the right.
The string to remove characters from.
The characters to be removed.
A copy of the string with characters removed from the right.
Returns the SHA-256 hash of the string as an array of bytes.
The string to hash.
The SHA-256 hash of the string.
Returns the SHA-256 hash of the string as a string.
The string to hash.
The SHA-256 hash of the string.
Returns the similarity index of the text compared to this string.
1 means totally similar and 0 means totally dissimilar.
The string to compare.
The other string to compare.
The similarity index.
Returns a simplified canonical path.
Split the string by a divisor string, return an array of the substrings.
Example "One,Two,Three" will return ["One","Two","Three"] if split by ",".
The string to split.
The divisor string that splits the string.
If , the array may include empty strings.
The array of strings split from the string.
Split the string in floats by using a divisor string, return an array of the substrings.
Example "1,2.5,3" will return [1,2.5,3] if split by ",".
The string to split.
The divisor string that splits the string.
If , the array may include empty floats.
The array of floats split from the string.
Returns a copy of the string stripped of any non-printable character at the beginning and the end.
The optional arguments are used to toggle stripping on the left and right edges respectively.
The string to strip.
If the left side should be stripped.
If the right side should be stripped.
The string stripped of any non-printable characters.
Returns part of the string from the position , with length .
The string to slice.
The position in the string that the part starts from.
The length of the returned part.
Part of the string from the position , with length .
Converts the String (which is a character array) to PoolByteArray (which is an array of bytes).
The conversion is speeded up in comparison to with the assumption
that all the characters the String contains are only ASCII characters.
The string to convert.
The string as ASCII encoded bytes.
Converts a string, containing a decimal number, into a .
The string to convert.
The number representation of the string.
Converts a string, containing an integer number, into an .
The string to convert.
The number representation of the string.
Returns the string converted to lowercase.
The string to convert.
The string converted to lowercase.
Returns the string converted to uppercase.
The string to convert.
The string converted to uppercase.
Converts the String (which is an array of characters) to PoolByteArray (which is an array of bytes).
The conversion is a bit slower than , but supports all UTF-8 characters.
Therefore, you should prefer this function over .
The string to convert.
The string as UTF-8 encoded bytes.
Returns a copy of the string with special characters escaped using the XML standard.
The string to escape.
The escaped string.
Returns a copy of the string with escaped characters replaced by their meanings
according to the XML standard.
The string to unescape.
The unescaped string.
3×4 matrix (3 rows, 4 columns) used for 3D linear transformations.
It can represent transformations such as translation, rotation, or scaling.
It consists of a (first 3 columns) and a
for the origin (last column).
For more information, read this documentation article:
https://docs.godotengine.org/en/3.5/tutorials/math/matrices_and_transforms.html
The of this transform. Contains the X, Y, and Z basis
vectors (columns 0 to 2) and is responsible for rotation and scale.
The origin vector (column 3, the fourth column). Equivalent to array index [3].
Access whole columns in the form of .
The fourth column is the vector.
Which column vector.
Access matrix elements in column-major order.
The fourth column is the vector.
Which column, the matrix horizontal position.
Which row, the matrix vertical position.
Returns the inverse of the transform, under the assumption that
the transformation is composed of rotation, scaling, and translation.
The inverse transformation matrix.
Interpolates this transform to the other by .
The other transform.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The interpolated transform.
Returns the inverse of the transform, under the assumption that
the transformation is composed of rotation and translation
(no scaling, use for transforms with scaling).
The inverse matrix.
Returns a copy of the transform rotated such that its
-Z axis (forward) points towards the position.
The transform will first be rotated around the given vector,
and then fully aligned to the by a further rotation around
an axis perpendicular to both the and vectors.
Operations take place in global space.
The object to look at.
The relative up direction.
The resulting transform.
Returns the transform with the basis orthogonal (90 degrees),
and normalized axis vectors (scale of 1 or -1).
The orthonormalized transform.
Rotates the transform around the given by (in radians),
using matrix multiplication. The axis must be a normalized vector.
The axis to rotate around. Must be normalized.
The angle to rotate, in radians.
The rotated transformation matrix.
Scales the transform by the given 3D scaling factor, using matrix multiplication.
The scale to introduce.
The scaled transformation matrix.
Translates the transform by the given ,
relative to the transform's basis vectors.
Unlike and ,
this does not use matrix multiplication.
The offset to translate by.
The translated matrix.
Returns a vector transformed (multiplied) by this transformation matrix.
A vector to transform.
The transformed vector.
Returns a vector transformed (multiplied) by the transposed transformation matrix.
Note: This results in a multiplication by the inverse of the
transformation matrix only if it represents a rotation-reflection.
A vector to inversely transform.
The inversely transformed vector.
The identity transform, with no translation, rotation, or scaling applied.
This is used as a replacement for Transform() in GDScript.
Do not use new Transform() with no arguments in C#, because it sets all values to zero.
Equivalent to new Transform(Vector3.Right, Vector3.Up, Vector3.Back, Vector3.Zero).
The transform that will flip something along the X axis.
Equivalent to new Transform(Vector3.Left, Vector3.Up, Vector3.Back, Vector3.Zero).
The transform that will flip something along the Y axis.
Equivalent to new Transform(Vector3.Right, Vector3.Down, Vector3.Back, Vector3.Zero).
The transform that will flip something along the Z axis.
Equivalent to new Transform(Vector3.Right, Vector3.Up, Vector3.Forward, Vector3.Zero).
Constructs a transformation matrix from 4 vectors (matrix columns).
The X vector, or column index 0.
The Y vector, or column index 1.
The Z vector, or column index 2.
The origin vector, or column index 3.
Constructs a transformation matrix from the given
and vector.
The to create the basis from.
The origin vector, or column index 3.
Constructs a transformation matrix from the given and
vector.
The to create the basis from.
The origin vector, or column index 3.
Composes these two transformation matrices by multiplying them
together. This has the effect of transforming the second transform
(the child) by the first transform (the parent).
The parent transform.
The child transform.
The composed transform.
Returns if the transforms are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left transform.
The right transform.
Whether or not the transforms are exactly equal.
Returns if the transforms are not equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left transform.
The right transform.
Whether or not the transforms are not equal.
Returns if the transform is exactly equal
to the given object ().
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The object to compare with.
Whether or not the transform and the object are exactly equal.
Returns if the transforms are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The other transform to compare.
Whether or not the matrices are exactly equal.
Returns if this transform and are approximately equal,
by running on each component.
The other transform to compare.
Whether or not the matrices are approximately equal.
Serves as the hash function for .
A hash code for this transform.
Converts this to a string.
A string representation of this transform.
Converts this to a string with the given .
A string representation of this transform.
2×3 matrix (2 rows, 3 columns) used for 2D linear transformations.
It can represent transformations such as translation, rotation, or scaling.
It consists of a three values: x, y, and the origin.
For more information, read this documentation article:
https://docs.godotengine.org/en/3.5/tutorials/math/matrices_and_transforms.html
The basis matrix's X vector (column 0). Equivalent to array index [0].
The basis matrix's Y vector (column 1). Equivalent to array index [1].
The origin vector (column 2, the third column). Equivalent to array index [2].
The origin vector represents translation.
The rotation of this transformation matrix.
Getting is equivalent to calling with the values of .
The scale of this transformation matrix.
Equivalent to the lengths of each column vector, but Y is negative if the determinant is negative.
Access whole columns in the form of .
The third column is the vector.
Which column vector.
Access matrix elements in column-major order.
The third column is the vector.
Which column, the matrix horizontal position.
Which row, the matrix vertical position.
Returns the inverse of the transform, under the assumption that
the transformation is composed of rotation, scaling, and translation.
The inverse transformation matrix.
Returns the determinant of the basis matrix. If the basis is
uniformly scaled, its determinant is the square of the scale.
A negative determinant means the Y scale is negative.
A zero determinant means the basis isn't invertible,
and is usually considered invalid.
The determinant of the basis matrix.
Returns a vector transformed (multiplied) by the basis matrix.
This method does not account for translation (the vector).
A vector to transform.
The transformed vector.
Returns a vector transformed (multiplied) by the inverse basis matrix.
This method does not account for translation (the vector).
Note: This results in a multiplication by the inverse of the
basis matrix only if it represents a rotation-reflection.
A vector to inversely transform.
The inversely transformed vector.
Interpolates this transform to the other by .
The other transform.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The interpolated transform.
Returns the inverse of the transform, under the assumption that
the transformation is composed of rotation and translation
(no scaling, use for transforms with scaling).
The inverse matrix.
Returns the transform with the basis orthogonal (90 degrees),
and normalized axis vectors (scale of 1 or -1).
The orthonormalized transform.
Rotates the transform by (in radians), using matrix multiplication.
The angle to rotate, in radians.
The rotated transformation matrix.
Scales the transform by the given scaling factor, using matrix multiplication.
The scale to introduce.
The scaled transformation matrix.
Translates the transform by the given ,
relative to the transform's basis vectors.
Unlike and ,
this does not use matrix multiplication.
The offset to translate by.
The translated matrix.
Returns a vector transformed (multiplied) by this transformation matrix.
A vector to transform.
The transformed vector.
Returns a vector transformed (multiplied) by the inverse transformation matrix.
A vector to inversely transform.
The inversely transformed vector.
The identity transform, with no translation, rotation, or scaling applied.
This is used as a replacement for Transform2D() in GDScript.
Do not use new Transform2D() with no arguments in C#, because it sets all values to zero.
Equivalent to new Transform2D(Vector2.Right, Vector2.Down, Vector2.Zero).
The transform that will flip something along the X axis.
Equivalent to new Transform2D(Vector2.Left, Vector2.Down, Vector2.Zero).
The transform that will flip something along the Y axis.
Equivalent to new Transform2D(Vector2.Right, Vector2.Up, Vector2.Zero).
Constructs a transformation matrix from 3 vectors (matrix columns).
The X vector, or column index 0.
The Y vector, or column index 1.
The origin vector, or column index 2.
Constructs a transformation matrix from the given components.
Arguments are named such that xy is equal to calling x.y
The X component of the X column vector, accessed via t.x.x or [0][0].
The Y component of the X column vector, accessed via t.x.y or [0][1].
The X component of the Y column vector, accessed via t.y.x or [1][0].
The Y component of the Y column vector, accessed via t.y.y or [1][1].
The X component of the origin vector, accessed via t.origin.x or [2][0].
The Y component of the origin vector, accessed via t.origin.y or [2][1].
Constructs a transformation matrix from a value and
vector.
The rotation of the new transform, in radians.
The origin vector, or column index 2.
Composes these two transformation matrices by multiplying them
together. This has the effect of transforming the second transform
(the child) by the first transform (the parent).
The parent transform.
The child transform.
The composed transform.
Returns a Vector2 transformed (multiplied) by transformation matrix.
The transformation to apply.
A Vector2 to transform.
The transformed Vector2.
Returns a Vector2 transformed (multiplied) by the inverse transformation matrix.
A Vector2 to inversely transform.
The transformation to apply.
The inversely transformed Vector2.
Returns a Rect2 transformed (multiplied) by transformation matrix.
The transformation to apply.
A Rect2 to transform.
The transformed Rect2.
Returns a Rect2 transformed (multiplied) by the inverse transformation matrix.
A Rect2 to inversely transform.
The transformation to apply.
The inversely transformed Rect2.
Returns a copy of the given Vector2[] transformed (multiplied) by transformation matrix.
The transformation to apply.
A Vector2[] to transform.
The transformed copy of the Vector2[].
Returns a copy of the given Vector2[] transformed (multiplied) by the inverse transformation matrix.
A Vector2[] to inversely transform.
The transformation to apply.
The inversely transformed copy of the Vector2[].
Returns if the transforms are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left transform.
The right transform.
Whether or not the transforms are exactly equal.
Returns if the transforms are not equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left transform.
The right transform.
Whether or not the transforms are not equal.
Returns if the transform is exactly equal
to the given object ().
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The object to compare with.
Whether or not the transform and the object are exactly equal.
Returns if the transforms are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The other transform to compare.
Whether or not the matrices are exactly equal.
Returns if this transform and are approximately equal,
by running on each component.
The other transform to compare.
Whether or not the matrices are approximately equal.
Serves as the hash function for .
A hash code for this transform.
Converts this to a string.
A string representation of this transform.
Converts this to a string with the given .
A string representation of this transform.
Event arguments for when unhandled exceptions occur.
Exception object.
2-element structure that can be used to represent positions in 2D space or any other pair of numeric values.
Enumerated index values for the axes.
Returned by and .
The vector's X axis.
The vector's Y axis.
The vector's X component. Also accessible by using the index position [0].
The vector's Y component. Also accessible by using the index position [1].
Access vector components using their index.
Thrown when the given the is not 0 or 1.
[0] is equivalent to ,
[1] is equivalent to .
Returns a new vector with all components in absolute values (i.e. positive).
A vector with called on each component.
Returns this vector's angle with respect to the X axis, or (1, 0) vector, in radians.
Equivalent to the result of when
called with the vector's and as parameters: Mathf.Atan2(v.y, v.x).
The angle of this vector, in radians.
Returns the angle to the given vector, in radians.
The other vector to compare this vector to.
The angle between the two vectors, in radians.
Returns the angle between the line connecting the two points and the X axis, in radians.
The other vector to compare this vector to.
The angle between the two vectors, in radians.
Returns the aspect ratio of this vector, the ratio of to .
The component divided by the component.
Returns the vector "bounced off" from a plane defined by the given normal.
The normal vector defining the plane to bounce off. Must be normalized.
The bounced vector.
Returns a new vector with all components rounded up (towards positive infinity).
A vector with called on each component.
Returns the vector with a maximum length by limiting its length to .
The length to limit to.
The vector with its length limited.
Returns the cross product of this vector and .
The other vector.
The cross product value.
Performs a cubic interpolation between vectors , this vector,
, and , by the given amount .
The destination vector.
A vector before this vector.
A vector after .
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The interpolated vector.
Returns the normalized vector pointing from this vector to .
The other vector to point towards.
The direction from this vector to .
Returns the squared distance between this vector and .
This method runs faster than , so prefer it if
you need to compare vectors or need the squared distance for some formula.
The other vector to use.
The squared distance between the two vectors.
Returns the distance between this vector and .
The other vector to use.
The distance between the two vectors.
Returns the dot product of this vector and .
The other vector to use.
The dot product of the two vectors.
Returns a new vector with all components rounded down (towards negative infinity).
A vector with called on each component.
Returns the inverse of this vector. This is the same as new Vector2(1 / v.x, 1 / v.y).
The inverse of this vector.
Returns if the vector is normalized, and otherwise.
A indicating whether or not the vector is normalized.
Returns the length (magnitude) of this vector.
The length of this vector.
Returns the squared length (squared magnitude) of this vector.
This method runs faster than , so prefer it if
you need to compare vectors or need the squared length for some formula.
The squared length of this vector.
Returns the result of the linear interpolation between
this vector and by amount .
The destination vector for interpolation.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting vector of the interpolation.
Returns the result of the linear interpolation between
this vector and by the vector amount .
The destination vector for interpolation.
A vector with components on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting vector of the interpolation.
Returns the vector with a maximum length by limiting its length to .
The length to limit to.
The vector with its length limited.
Returns the axis of the vector's largest value. See .
If both components are equal, this method returns .
The index of the largest axis.
Returns the axis of the vector's smallest value. See .
If both components are equal, this method returns .
The index of the smallest axis.
Moves this vector toward by the fixed amount.
The vector to move towards.
The amount to move towards by.
The resulting vector.
Returns the vector scaled to unit length. Equivalent to v / v.Length().
A normalized version of the vector.
Returns a perpendicular vector rotated 90 degrees counter-clockwise
compared to the original, with the same length.
The perpendicular vector.
Returns a vector composed of the of this vector's components
and .
A value representing the divisor of the operation.
A vector with each component by .
Returns a vector composed of the of this vector's components
and 's components.
A vector representing the divisors of the operation.
A vector with each component by 's components.
Returns this vector projected onto another vector .
The vector to project onto.
The projected vector.
Returns this vector reflected from a plane defined by the given .
The normal vector defining the plane to reflect from. Must be normalized.
The reflected vector.
Rotates this vector by radians.
The angle to rotate by, in radians.
The rotated vector.
Returns this vector with all components rounded to the nearest integer,
with halfway cases rounded towards the nearest multiple of two.
The rounded vector.
Returns a vector with each component set to one or negative one, depending
on the signs of this vector's components, or zero if the component is zero,
by calling on each component.
A vector with all components as either 1, -1, or 0.
Returns the result of the spherical linear interpolation between
this vector and by amount .
Note: Both vectors must be normalized.
The destination vector for interpolation. Must be normalized.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting vector of the interpolation.
Returns this vector slid along a plane defined by the given .
The normal vector defining the plane to slide on.
The slid vector.
Returns this vector with each component snapped to the nearest multiple of .
This can also be used to round to an arbitrary number of decimals.
A vector value representing the step size to snap to.
The snapped vector.
Returns a perpendicular vector rotated 90 degrees counter-clockwise
compared to the original, with the same length.
Deprecated, will be replaced by in 4.0.
The perpendicular vector.
Zero vector, a vector with all components set to 0.
Equivalent to new Vector2(0, 0).
Deprecated, please use a negative sign with instead.
Equivalent to new Vector2(-1, -1).
One vector, a vector with all components set to 1.
Equivalent to new Vector2(1, 1).
Infinity vector, a vector with all components set to .
Equivalent to new Vector2(Mathf.Inf, Mathf.Inf).
Up unit vector. Y is down in 2D, so this vector points -Y.
Equivalent to new Vector2(0, -1).
Down unit vector. Y is down in 2D, so this vector points +Y.
Equivalent to new Vector2(0, 1).
Right unit vector. Represents the direction of right.
Equivalent to new Vector2(1, 0).
Left unit vector. Represents the direction of left.
Equivalent to new Vector2(-1, 0).
Constructs a new with the given components.
The vector's X component.
The vector's Y component.
Constructs a new from an existing .
The existing .
Adds each component of the
with the components of the given .
The left vector.
The right vector.
The added vector.
Subtracts each component of the
by the components of the given .
The left vector.
The right vector.
The subtracted vector.
Returns the negative value of the .
This is the same as writing new Vector2(-v.x, -v.y).
This operation flips the direction of the vector while
keeping the same magnitude.
With floats, the number zero can be either positive or negative.
The vector to negate/flip.
The negated/flipped vector.
Multiplies each component of the
by the given .
The vector to multiply.
The scale to multiply by.
The multiplied vector.
Multiplies each component of the
by the given .
The scale to multiply by.
The vector to multiply.
The multiplied vector.
Multiplies each component of the
by the components of the given .
The left vector.
The right vector.
The multiplied vector.
Multiplies each component of the
by the given .
The dividend vector.
The divisor value.
The divided vector.
Divides each component of the
by the components of the given .
The dividend vector.
The divisor vector.
The divided vector.
Gets the remainder of each component of the
with the components of the given .
This operation uses truncated division, which is often not desired
as it does not work well with negative numbers.
Consider using instead
if you want to handle negative numbers.
GD.Print(new Vector2(10, -20) % 7); // Prints "(3, -6)"
The dividend vector.
The divisor value.
The remainder vector.
Gets the remainder of each component of the
with the components of the given .
This operation uses truncated division, which is often not desired
as it does not work well with negative numbers.
Consider using instead
if you want to handle negative numbers.
GD.Print(new Vector2(10, -20) % new Vector2(7, 8)); // Prints "(3, -4)"
The dividend vector.
The divisor vector.
The remainder vector.
Returns if the vectors are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left vector.
The right vector.
Whether or not the vectors are exactly equal.
Returns if the vectors are not equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left vector.
The right vector.
Whether or not the vectors are not equal.
Compares two vectors by first checking if
the X value of the vector is less than
the X value of the vector.
If the X values are exactly equal, then it repeats this check
with the Y values of the two vectors.
This operator is useful for sorting vectors.
The left vector.
The right vector.
Whether or not the left is less than the right.
Compares two vectors by first checking if
the X value of the vector is greater than
the X value of the vector.
If the X values are exactly equal, then it repeats this check
with the Y values of the two vectors.
This operator is useful for sorting vectors.
The left vector.
The right vector.
Whether or not the left is greater than the right.
Compares two vectors by first checking if
the X value of the vector is less than
or equal to the X value of the vector.
If the X values are exactly equal, then it repeats this check
with the Y values of the two vectors.
This operator is useful for sorting vectors.
The left vector.
The right vector.
Whether or not the left is less than or equal to the right.
Compares two vectors by first checking if
the X value of the vector is greater than
or equal to the X value of the vector.
If the X values are exactly equal, then it repeats this check
with the Y values of the two vectors.
This operator is useful for sorting vectors.
The left vector.
The right vector.
Whether or not the left is greater than or equal to the right.
Returns if the vector is exactly equal
to the given object ().
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The object to compare with.
Whether or not the vector and the object are equal.
Returns if the vectors are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The other vector.
Whether or not the vectors are exactly equal.
Returns if this vector and are approximately equal,
by running on each component.
The other vector to compare.
Whether or not the vectors are approximately equal.
Serves as the hash function for .
A hash code for this vector.
Converts this to a string.
A string representation of this vector.
Converts this to a string with the given .
A string representation of this vector.
3-element structure that can be used to represent positions in 3D space or any other pair of numeric values.
Enumerated index values for the axes.
Returned by and .
The vector's X axis.
The vector's Y axis.
The vector's Z axis.
The vector's X component. Also accessible by using the index position [0].
The vector's Y component. Also accessible by using the index position [1].
The vector's Z component. Also accessible by using the index position [2].
Access vector components using their index.
Thrown when the given the is not 0, 1 or 2.
[0] is equivalent to ,
[1] is equivalent to ,
[2] is equivalent to .
Returns a new vector with all components in absolute values (i.e. positive).
A vector with called on each component.
Returns the unsigned minimum angle to the given vector, in radians.
The other vector to compare this vector to.
The unsigned angle between the two vectors, in radians.
Returns this vector "bounced off" from a plane defined by the given normal.
The normal vector defining the plane to bounce off. Must be normalized.
The bounced vector.
Returns a new vector with all components rounded up (towards positive infinity).
A vector with called on each component.
Returns the cross product of this vector and .
The other vector.
The cross product vector.
Performs a cubic interpolation between vectors , this vector,
, and , by the given amount .
The destination vector.
A vector before this vector.
A vector after .
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The interpolated vector.
Returns the normalized vector pointing from this vector to .
The other vector to point towards.
The direction from this vector to .
Returns the squared distance between this vector and .
This method runs faster than , so prefer it if
you need to compare vectors or need the squared distance for some formula.
The other vector to use.
The squared distance between the two vectors.
Returns the distance between this vector and .
The other vector to use.
The distance between the two vectors.
Returns the dot product of this vector and .
The other vector to use.
The dot product of the two vectors.
Returns a new vector with all components rounded down (towards negative infinity).
A vector with called on each component.
Returns the inverse of this vector. This is the same as new Vector3(1 / v.x, 1 / v.y, 1 / v.z).
The inverse of this vector.
Returns if the vector is normalized, and otherwise.
A indicating whether or not the vector is normalized.
Returns the length (magnitude) of this vector.
The length of this vector.
Returns the squared length (squared magnitude) of this vector.
This method runs faster than , so prefer it if
you need to compare vectors or need the squared length for some formula.
The squared length of this vector.
Returns the result of the linear interpolation between
this vector and by amount .
The destination vector for interpolation.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting vector of the interpolation.
Returns the result of the linear interpolation between
this vector and by the vector amount .
The destination vector for interpolation.
A vector with components on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting vector of the interpolation.
Returns the vector with a maximum length by limiting its length to .
The length to limit to.
The vector with its length limited.
Returns the axis of the vector's largest value. See .
If all components are equal, this method returns .
The index of the largest axis.
Returns the axis of the vector's smallest value. See .
If all components are equal, this method returns .
The index of the smallest axis.
Moves this vector toward by the fixed amount.
The vector to move towards.
The amount to move towards by.
The resulting vector.
Returns the vector scaled to unit length. Equivalent to v / v.Length().
A normalized version of the vector.
Returns the outer product with .
The other vector.
A representing the outer product matrix.
Returns a vector composed of the of this vector's components
and .
A value representing the divisor of the operation.
A vector with each component by .
Returns a vector composed of the of this vector's components
and 's components.
A vector representing the divisors of the operation.
A vector with each component by 's components.
Returns this vector projected onto another vector .
The vector to project onto.
The projected vector.
Returns this vector reflected from a plane defined by the given .
The normal vector defining the plane to reflect from. Must be normalized.
The reflected vector.
Rotates this vector around a given vector by (in radians).
The vector must be a normalized vector.
The vector to rotate around. Must be normalized.
The angle to rotate by, in radians.
The rotated vector.
Returns this vector with all components rounded to the nearest integer,
with halfway cases rounded towards the nearest multiple of two.
The rounded vector.
Returns a vector with each component set to one or negative one, depending
on the signs of this vector's components, or zero if the component is zero,
by calling on each component.
A vector with all components as either 1, -1, or 0.
Returns the signed angle to the given vector, in radians.
The sign of the angle is positive in a counter-clockwise
direction and negative in a clockwise direction when viewed
from the side specified by the .
The other vector to compare this vector to.
The reference axis to use for the angle sign.
The signed angle between the two vectors, in radians.
Returns the result of the spherical linear interpolation between
this vector and by amount .
Note: Both vectors must be normalized.
The destination vector for interpolation. Must be normalized.
A value on the range of 0.0 to 1.0, representing the amount of interpolation.
The resulting vector of the interpolation.
Returns this vector slid along a plane defined by the given .
The normal vector defining the plane to slide on.
The slid vector.
Returns this vector with each component snapped to the nearest multiple of .
This can also be used to round to an arbitrary number of decimals.
A vector value representing the step size to snap to.
The snapped vector.
Returns a diagonal matrix with the vector as main diagonal.
This is equivalent to a with no rotation or shearing and
this vector's components set as the scale.
A with the vector as its main diagonal.
Zero vector, a vector with all components set to 0.
Equivalent to new Vector3(0, 0, 0).
One vector, a vector with all components set to 1.
Equivalent to new Vector3(1, 1, 1).
Deprecated, please use a negative sign with instead.
Equivalent to new Vector3(-1, -1, -1).
Infinity vector, a vector with all components set to .
Equivalent to new Vector3(Mathf.Inf, Mathf.Inf, Mathf.Inf).
Up unit vector.
Equivalent to new Vector3(0, 1, 0).
Down unit vector.
Equivalent to new Vector3(0, -1, 0).
Right unit vector. Represents the local direction of right,
and the global direction of east.
Equivalent to new Vector3(1, 0, 0).
Left unit vector. Represents the local direction of left,
and the global direction of west.
Equivalent to new Vector3(-1, 0, 0).
Forward unit vector. Represents the local direction of forward,
and the global direction of north.
Equivalent to new Vector3(0, 0, -1).
Back unit vector. Represents the local direction of back,
and the global direction of south.
Equivalent to new Vector3(0, 0, 1).
Constructs a new with the given components.
The vector's X component.
The vector's Y component.
The vector's Z component.
Constructs a new from an existing .
The existing .
Adds each component of the
with the components of the given .
The left vector.
The right vector.
The added vector.
Subtracts each component of the
by the components of the given .
The left vector.
The right vector.
The subtracted vector.
Returns the negative value of the .
This is the same as writing new Vector3(-v.x, -v.y, -v.z).
This operation flips the direction of the vector while
keeping the same magnitude.
With floats, the number zero can be either positive or negative.
The vector to negate/flip.
The negated/flipped vector.
Multiplies each component of the
by the given .
The vector to multiply.
The scale to multiply by.
The multiplied vector.
Multiplies each component of the
by the given .
The scale to multiply by.
The vector to multiply.
The multiplied vector.
Multiplies each component of the
by the components of the given .
The left vector.
The right vector.
The multiplied vector.
Divides each component of the
by the given .
The dividend vector.
The divisor value.
The divided vector.
Divides each component of the
by the components of the given .
The dividend vector.
The divisor vector.
The divided vector.
Gets the remainder of each component of the
with the components of the given .
This operation uses truncated division, which is often not desired
as it does not work well with negative numbers.
Consider using instead
if you want to handle negative numbers.
GD.Print(new Vector3(10, -20, 30) % 7); // Prints "(3, -6, 2)"
The dividend vector.
The divisor value.
The remainder vector.
Gets the remainder of each component of the
with the components of the given .
This operation uses truncated division, which is often not desired
as it does not work well with negative numbers.
Consider using instead
if you want to handle negative numbers.
GD.Print(new Vector3(10, -20, 30) % new Vector3(7, 8, 9)); // Prints "(3, -4, 3)"
The dividend vector.
The divisor vector.
The remainder vector.
Returns if the vectors are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left vector.
The right vector.
Whether or not the vectors are exactly equal.
Returns if the vectors are not equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The left vector.
The right vector.
Whether or not the vectors are not equal.
Compares two vectors by first checking if
the X value of the vector is less than
the X value of the vector.
If the X values are exactly equal, then it repeats this check
with the Y values of the two vectors, and then with the Z values.
This operator is useful for sorting vectors.
The left vector.
The right vector.
Whether or not the left is less than the right.
Compares two vectors by first checking if
the X value of the vector is greater than
the X value of the vector.
If the X values are exactly equal, then it repeats this check
with the Y values of the two vectors, and then with the Z values.
This operator is useful for sorting vectors.
The left vector.
The right vector.
Whether or not the left is greater than the right.
Compares two vectors by first checking if
the X value of the vector is less than
or equal to the X value of the vector.
If the X values are exactly equal, then it repeats this check
with the Y values of the two vectors, and then with the Z values.
This operator is useful for sorting vectors.
The left vector.
The right vector.
Whether or not the left is less than or equal to the right.
Compares two vectors by first checking if
the X value of the vector is greater than
or equal to the X value of the vector.
If the X values are exactly equal, then it repeats this check
with the Y values of the two vectors, and then with the Z values.
This operator is useful for sorting vectors.
The left vector.
The right vector.
Whether or not the left is greater than or equal to the right.
Returns if the vector is exactly equal
to the given object ().
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The object to compare with.
Whether or not the vector and the object are equal.
Returns if the vectors are exactly equal.
Note: Due to floating-point precision errors, consider using
instead, which is more reliable.
The other vector.
Whether or not the vectors are exactly equal.
Returns if this vector and are approximately equal,
by running on each component.
The other vector to compare.
Whether or not the vectors are approximately equal.
Serves as the hash function for .
A hash code for this vector.
Converts this to a string.
A string representation of this vector.
Converts this to a string with the given .
A string representation of this vector.
Left margin, usually used for or -derived classes.
Top margin, usually used for or -derived classes.
Right margin, usually used for or -derived classes.
Bottom margin, usually used for or -derived classes.
Top-left corner.
Top-right corner.
Bottom-right corner.
Bottom-left corner.
General vertical alignment, usually used for , , , etc.
General horizontal alignment, usually used for , , , etc.
Horizontal left alignment, usually for text-derived classes.
Horizontal center alignment, usually for text-derived classes.
Horizontal right alignment, 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.
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.
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.
Left Super key (Windows key).
Right Super key (Windows key).
Context menu key.
Left Hyper key.
Right Hyper key.
Help key.
Left Direction key.
Right Direction 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.
Bass Boost key.
Bass up key.
Bass down key.
Treble up key.
Treble down 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.
Number 1.
Number 2.
Number 3.
Number 4.
Number 5.
Number 6.
Number 7.
Number 8.
Number 9.
: 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.
Non-breakable space key.
¡ key.
¢ key.
£ key.
¤ key.
¥ key.
¦ key.
§ key.
¨ key.
© key.
ª key.
« key.
¬ key.
Soft hyphen key.
® key.
¯ key.
° key.
± key.
² key.
³ key.
´ key.
µ key.
¶ key.
· key.
¸ key.
¹ key.
º key.
» key.
¼ key.
½ key.
¾ key.
¿ key.
À key.
Á key.
 key.
à key.
Ä key.
Å key.
Æ key.
Ç key.
È key.
É key.
Ê key.
Ë key.
Ì key.
Í key.
Î key.
Ï key.
Ð key.
Ñ key.
Ò key.
Ó key.
Ô key.
Õ key.
Ö key.
× key.
Ø key.
Ù key.
Ú key.
Û key.
Ü key.
Ý key.
Þ key.
ß key.
÷ key.
ÿ key.
Key Code mask.
Modifier key mask.
Shift key mask.
Alt key mask.
Meta key mask.
Ctrl key mask.
Command key mask. On macOS, this is equivalent to KEY_MASK_META. On other platforms, this is equivalent to KEY_MASK_CTRL. This mask should be preferred to KEY_MASK_META or KEY_MASK_CTRL for system shortcuts as it handles all platforms correctly.
Keypad key mask.
Group Switch key mask.
Left mouse button.
Right mouse button.
Middle mouse button.
Extra mouse button 1 (only present on some mice).
Extra mouse button 2 (only present on some mice).
Mouse wheel up.
Mouse wheel down.
Mouse wheel left button (only present on some mice).
Mouse wheel right button (only present on some mice).
Left mouse button mask.
Right mouse button mask.
Middle mouse button mask.
Extra mouse button 1 mask.
Extra mouse button 2 mask.
Invalid button or axis.
Gamepad button 0.
Gamepad button 1.
Gamepad button 2.
Gamepad button 3.
Gamepad button 4.
Gamepad button 5.
Gamepad button 6.
Gamepad button 7.
Gamepad button 8.
Gamepad button 9.
Gamepad button 10.
Gamepad button 11.
Gamepad button 12.
Gamepad button 13.
Gamepad button 14.
Gamepad button 15.
Gamepad button 16.
Gamepad button 17.
Gamepad button 18.
Gamepad button 19.
Gamepad button 20.
Gamepad button 21.
Gamepad button 22.
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.
DualShock circle button.
DualShock X button.
DualShock square button.
DualShock triangle button.
Xbox controller B button.
Xbox controller A button.
Xbox controller X button.
Xbox controller Y button.
Nintendo controller A button.
Nintendo controller B button.
Nintendo controller X button.
Nintendo controller Y button.
Grip (side) buttons on a VR controller.
Push down on the touchpad or main joystick on a VR controller.
Trigger on a VR controller.
A button on the right Oculus Touch controller, X button on the left controller (also when used in OpenVR).
B button on the right Oculus Touch controller, Y button on the left controller (also when used in OpenVR).
Menu button on either Oculus Touch controller.
Menu button in OpenVR (Except when Oculus Touch controllers are used).
Gamepad button Select.
Gamepad button Start.
Gamepad DPad up.
Gamepad DPad down.
Gamepad DPad left.
Gamepad DPad right.
Gamepad SDL guide button.
Gamepad SDL miscellaneous button.
Gamepad SDL paddle 1 button.
Gamepad SDL paddle 2 button.
Gamepad SDL paddle 3 button.
Gamepad SDL paddle 4 button.
Gamepad SDL touchpad button.
Gamepad left Shoulder button.
Gamepad left trigger.
Gamepad left stick click.
Gamepad right Shoulder button.
Gamepad right trigger.
Gamepad right stick click.
Gamepad left stick horizontal axis.
Gamepad left stick vertical axis.
Gamepad right stick horizontal axis.
Gamepad right stick vertical axis.
Generic gamepad axis 4.
Generic gamepad axis 5.
Gamepad left trigger analog axis.
Gamepad right trigger analog axis.
Generic gamepad axis 8.
Generic gamepad axis 9.
Represents the maximum number of joystick axes supported.
Gamepad left stick horizontal axis.
Gamepad left stick vertical axis.
Gamepad right stick horizontal axis.
Gamepad right stick vertical axis.
Gamepad left analog trigger.
Gamepad right analog trigger.
VR Controller analog trigger.
VR Controller analog grip (side buttons).
OpenVR touchpad X axis (Joystick axis on Oculus Touch and Windows MR controllers).
OpenVR touchpad Y axis (Joystick axis on Oculus Touch and Windows MR controllers).
MIDI note OFF message. See the documentation of for information of how to use MIDI inputs.
MIDI note ON message. See the documentation of 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 return OK when no error occurred. Note that many functions don't return an error code but will print error messages to standard output.
Since OK has value 0, and all other failure codes are positive integers, it can also be used in boolean checks, e.g.:
var err = method_that_returns_error()
if err != OK:
print("Failure!")
# Or, equivalent:
if err:
print("Still failing!")
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.
Bug error.
Printer on fire error. (This is an easter egg, no engine methods return this error code.)
No hint for the edited property.
Hints that an integer 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_lesser" to allow manual input going respectively above the max or below the min values. Example: "-360,360,1,or_greater,or_lesser".
Hints that a float property should be within an exponential range specified via the hint string "min,max" or "min,max,step". The hint string can optionally include "or_greater" and/or "or_lesser" to allow manual input going respectively above the max or below the min values. Example: "0.01,100,0.01,or_greater".
Hints that an integer, float 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". For integer and float 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".
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.
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 "inout" to also include in/out easing.
Deprecated hint, unused.
Deprecated hint, unused.
Hints that an integer property is a bitmask with named bit flags. For example, to allow toggling bits 0, 1, 2 and 4, the hint could be something like "Bit0,Bit1,Bit2,,Bit4".
Hints that an integer property is a bitmask using the optionally named 2D render layers.
Hints that an integer property is a bitmask using the optionally named 2D physics layers.
Hints that an integer property is a bitmask using the optionally named 2D navigation layers.
Hints that an integer property is a bitmask using the optionally named 3D render layers.
Hints that an integer property is a bitmask using the optionally named 3D physics layers.
Hints that an integer 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 "*.png,*.jpg".
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 "*.png,*.jpg".
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 -derived type, optionally specified via the hint string (e.g. "Texture"). 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 should have a placeholder text visible on its input field, whenever the property is empty. The hint string is the placeholder text to use.
Hints that a color property should be edited without changing its alpha component, i.e. only R, G and B channels are edited.
Hints that an image is compressed using lossy compression.
Hints that an image is compressed using lossless compression.
The property is serialized and saved in the scene file (default).
The property is shown in the editor inspector (default).
Deprecated usage flag, unused.
Deprecated usage flag, unused.
The property can be checked in the editor inspector.
The property is checked in the editor inspector.
The property is a translatable string.
Used to group properties together in the editor. See .
Used to categorize properties together in the editor.
The property does not save its state in .
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.
Default usage (storage, editor and network).
Default usage for translatable strings (storage, editor, network and internationalized).
Default usage but without showing the property in the editor (storage, network).
Flag for a normal method.
Flag for an editor method.
Deprecated method flag, unused.
Flag for a constant method.
Deprecated method flag, unused.
Flag for a virtual method.
Deprecated method flag, unused.
Default method flags.
Variable is null.
Variable is of type .
Variable is of type .
Variable is of type (real).
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Variable is of type .
Represents the size of the enum.
Equality operator (==).
Inequality operator (!=).
Less than operator (<).
Less than or equal operator (<=).
Greater than operator (>).
Greater than or equal operator (>=).
Addition operator (+).
Subtraction operator (-).
Multiplication operator (*).
Division operator (/).
Unary negation operator (-).
Unary plus operator (+).
Remainder/modulo operator (%).
String concatenation operator (+).
Left shift operator (<<).
Right shift operator (>>).
Bitwise AND operator (&).
Bitwise OR operator (|).
Bitwise XOR operator (^).
Bitwise NOT operator (~).
Logical AND operator (and or &&).
Logical OR operator (or or ||).
Logical XOR operator (not implemented in GDScript).
Logical NOT operator (not or !).
Logical IN operator (in).
Represents the size of the enum.
This class provides access to AES encryption/decryption of raw data. Both AES-ECB and AES-CBC mode are supported.
extends Node
var aes = AESContext.new()
func _ready():
var key = "My secret key!!!" # Key must be either 16 or 32 bytes.
var data = "My secret text!!" # Data size must be multiple of 16 bytes, apply padding if needed.
# Encrypt ECB
aes.start(AESContext.MODE_ECB_ENCRYPT, key.to_utf8())
var encrypted = aes.update(data.to_utf8())
aes.finish()
# Decrypt ECB
aes.start(AESContext.MODE_ECB_DECRYPT, key.to_utf8())
var decrypted = aes.update(encrypted)
aes.finish()
# Check ECB
assert(decrypted == data.to_utf8())
var iv = "My secret iv!!!!" # IV must be of exactly 16 bytes.
# Encrypt CBC
aes.start(AESContext.MODE_CBC_ENCRYPT, key.to_utf8(), iv.to_utf8())
encrypted = aes.update(data.to_utf8())
aes.finish()
# Decrypt CBC
aes.start(AESContext.MODE_CBC_DECRYPT, key.to_utf8(), iv.to_utf8())
decrypted = aes.update(encrypted)
aes.finish()
# Check CBC
assert(decrypted == data.to_utf8())
AES electronic codebook encryption mode.
AES electronic codebook decryption mode.
AES cipher blocker chaining encryption mode.
AES cipher blocker chaining decryption mode.
Maximum value for the mode enum.
Start the AES context in the given mode. A key of either 16 or 32 bytes must always be provided, while an iv (initialization vector) of exactly 16 bytes, is only needed when mode is either or .
If the parameter is null, then the default value is Array.Empty<byte>()
Run the desired operation for this AES context. Will return a containing the result of encrypting (or decrypting) the given src. See for mode of operation.
Note: The size of src must be a multiple of 16. Apply some padding if needed.
Get the current IV state for this context (IV gets updated when calling ). You normally don't need this function.
Note: This function only makes sense when the context is started with or .
Close this AES context so it can be started again. See .
The point is a spatial node that maps a real world location identified by the AR platform to a position within the game world. For example, as long as plane detection in ARKit is on, ARKit will identify and update the position of planes (tables, floors, etc) and create anchors for them.
This node is mapped to one of the anchors through its unique ID. When you receive a signal that a new anchor is available, you should add this node to your scene for that anchor. You can predefine nodes and set the ID; the nodes will simply remain on 0,0,0 until a plane is recognized.
Keep in mind that, as long as plane detection is enabled, the size, placing and orientation of an anchor will be updated as the detection logic learns more about the real world out there especially if only part of the surface is in view.
The anchor's ID. You can set this before the anchor itself exists. The first anchor gets an ID of 1, the second an ID of 2, etc. When anchors get removed, the engine can then assign the corresponding ID to new anchors. The most common situation where anchors "disappear" is when the AR server identifies that two anchors represent different parts of the same plane and merges them.
Returns the name given to this anchor.
Returns true if the anchor is being tracked and false if no anchor with this ID is currently known.
Returns the estimated size of the plane that was detected. Say when the anchor relates to a table in the real world, this is the estimated size of the surface of that table.
Returns a plane aligned with our anchor; handy for intersection testing.
If provided by the , this returns a mesh object for the anchor. For an anchor, this can be a shape related to the object being tracked or it can be a mesh that provides topology related to the anchor and can be used to create shadows/reflections on surfaces or for generating collision shapes.
This is a helper spatial node for our camera; note that, if stereoscopic rendering is applicable (VR-HMD), most of the camera properties are ignored, as the HMD information overrides them. The only properties that can be trusted are the near and far planes.
The position and orientation of this node is automatically updated by the ARVR Server to represent the location of the HMD if such tracking is available and can thus be used by game logic. Note that, in contrast to the ARVR Controller, the render thread has access to the most up-to-date tracking data of the HMD and the location of the ARVRCamera can lag a few milliseconds behind what is used for rendering as a result.
This is a helper spatial node that is linked to the tracking of controllers. It also offers several handy passthroughs to the state of buttons and such on the controllers.
Controllers are linked by their ID. You can create controller nodes before the controllers are available. If your game always uses two controllers (one for each hand), you can predefine the controllers with ID 1 and 2; they will become active as soon as the controllers are identified. If you expect additional controllers to be used, you should react to the signals and add ARVRController nodes to your scene.
The position of the controller node is automatically updated by the . This makes this node ideal to add child nodes to visualize the controller.
The controller's ID.
A controller ID of 0 is unbound and will always result in an inactive node. Controller ID 1 is reserved for the first controller that identifies itself as the left-hand controller and ID 2 is reserved for the first controller that identifies itself as the right-hand controller.
For any other controller that the detects, we continue with controller ID 3.
When a controller is turned off, its slot is freed. This ensures controllers will keep the same ID even when controllers with lower IDs are turned off.
The degree to which the controller vibrates. Ranges from 0.0 to 1.0. If changed, updates accordingly.
This is a useful property to animate if you want the controller to vibrate for a limited duration.
If active, returns the name of the associated controller if provided by the AR/VR SDK used.
Returns the ID of the joystick object bound to this. Every controller tracked by the that has buttons and axis will also be registered as a joystick within Godot. This means that all the normal joystick tracking and input mapping will work for buttons and axis found on the AR/VR controllers. This ID is purely offered as information so you can link up the controller with its joystick entry.
Returns true if the button at index button is pressed. See , in particular the JOY_VR_* constants.
Returns the value of the given axis for things like triggers, touchpads, etc. that are embedded into the controller.
Returns true if the bound controller is active. ARVR systems attempt to track active controllers.
Returns the hand holding this controller, if known. See .
If provided by the , this returns a mesh associated with the controller. This can be used to visualize the controller.
This class needs to be implemented to make an AR or VR platform available to Godot and these should be implemented as C++ modules or GDNative modules (note that for GDNative the subclass ARVRScriptInterface should be used). Part of the interface is exposed to GDScript so you can detect, enable and configure an AR or VR platform.
Interfaces should be written in such a way that simply enabling them will give us a working setup. You can query the available interfaces through .
Tracking is behaving as expected.
Tracking is hindered by excessive motion (the player is moving faster than tracking can keep up).
Tracking is hindered by insufficient features, it's too dark (for camera-based tracking), player is blocked, etc.
We don't know the status of the tracking or this interface does not provide feedback.
Tracking is not functional (camera not plugged in or obscured, lighthouses turned off, etc.).
Mono output, this is mostly used internally when retrieving positioning information for our camera node or when stereo scopic rendering is not supported.
Left eye output, this is mostly used internally when rendering the image for the left eye and obtaining positioning and projection information.
Right eye output, this is mostly used internally when rendering the image for the right eye and obtaining positioning and projection information.
No ARVR capabilities.
This interface can work with normal rendering output (non-HMD based AR).
This interface supports stereoscopic rendering.
This interface supports AR (video background and real world tracking).
This interface outputs to an external device. If the main viewport is used, the on screen output is an unmodified buffer of either the left or right eye (stretched if the viewport size is not changed to the same aspect ratio of ). Using a separate viewport node frees up the main viewport for other purposes.
true if this is the primary interface.
true if this interface been initialized.
On an AR interface, true if anchor detection is enabled.
Returns the name of this interface (OpenVR, OpenHMD, ARKit, etc).
Returns a combination of flags providing information about the capabilities of this interface.
Call this to initialize this interface. The first interface that is initialized is identified as the primary interface and it will be used for rendering output.
After initializing the interface you want to use you then need to enable the AR/VR mode of a viewport and rendering should commence.
Note: You must enable the AR/VR mode on the main viewport for any device that uses the main output of Godot, such as for mobile VR.
If you do this for a platform that handles its own output (such as OpenVR) Godot will show just one eye without distortion on screen. Alternatively, you can add a separate viewport node to your scene and enable AR/VR on that viewport. It will be used to output to the HMD, leaving you free to do anything you like in the main window, such as using a separate camera as a spectator camera or rendering something completely different.
While currently not used, you can activate additional interfaces. You may wish to do this if you want to track controllers from other platforms. However, at this point in time only one interface can render to an HMD.
Turns the interface off.
If supported, returns the status of our tracking. This will allow you to provide feedback to the user whether there are issues with positional tracking.
Returns the resolution at which we should render our intermediate results before things like lens distortion are applied by the VR platform.
Returns true if the current output of this interface is in stereo.
If this is an AR interface that requires displaying a camera feed as the background, this method returns the feed ID in the for this interface.
This is a wrapper class for GDNative implementations of the ARVR interface. To use a GDNative ARVR interface, simply instantiate this object and set your GDNative library containing the ARVR interface implementation.
This is a special node within the AR/VR system that maps the physical location of the center of our tracking space to the virtual location within our game world.
There should be only one of these nodes in your scene and you must have one. All the ARVRCamera, ARVRController and ARVRAnchor nodes should be direct children of this node for spatial tracking to work correctly.
It is the position of this node that you update when your character needs to move through your game world while we're not moving in the real world. Movement in the real world is always in relation to this origin point.
For example, if your character is driving a car, the ARVROrigin node should be a child node of this car. Or, if you're implementing a teleport system to move your character, you should change the position of this node.
Allows you to adjust the scale to your game's units. Most AR/VR platforms assume a scale of 1 game world unit = 1 real world meter.
Note: This method is a passthrough to the itself.
An instance of this object represents a device that is tracked, such as a controller or anchor point. HMDs aren't represented here as they are handled internally.
As controllers are turned on and the AR/VR interface detects them, instances of this object are automatically added to this list of active tracking objects accessible through the .
The and both consume objects of this type and should be used in your project. The positional trackers are just under-the-hood objects that make this all work. These are mostly exposed so that GDNative-based interfaces can interact with them.
The hand this tracker is held in is unknown or not applicable.
This tracker is the left hand controller.
This tracker is the right hand controller.
The degree to which the tracker rumbles. Ranges from 0.0 to 1.0 with precision .01.
Returns the tracker's type.
Returns the internal tracker ID. This uniquely identifies the tracker per tracker type and matches the ID you need to specify for nodes such as the and nodes.
Returns the controller or anchor point's name if available.
If this is a controller that is being tracked, the controller will also be represented by a joystick entry with this ID.
Returns true if this device tracks orientation.
Returns the controller's orientation matrix.
Returns true if this device tracks position.
Returns the world-space controller position.
Returns the hand holding this tracker, if known. See constants.
Returns the transform combining this device's orientation and position.
Returns the mesh related to a controller or anchor point if one is available.
The AR/VR server is the heart of our Advanced and Virtual Reality solution and handles all the processing.
Fully reset the orientation of the HMD. Regardless of what direction the user is looking to in the real world. The user will look dead ahead in the virtual world.
Resets the orientation but keeps the tilt of the device. So if we're looking down, we keep looking down but heading will be reset.
Does not reset the orientation of the HMD, only the position of the player gets centered.
The tracker tracks the location of a controller.
The tracker tracks the location of a base station.
The tracker tracks the location and size of an AR anchor.
Used internally to filter trackers of any known type.
Used internally if we haven't set the tracker type yet.
Used internally to select all trackers.
Allows you to adjust the scale to your game's units. Most AR/VR platforms assume a scale of 1 game world unit = 1 real world meter.
The primary currently bound to the .
Returns the reference frame transform. Mostly used internally and exposed for GDNative build interfaces.
This is an important function to understand correctly. AR and VR platforms all handle positioning slightly differently.
For platforms that do not offer spatial tracking, our origin point (0,0,0) is the location of our HMD, but you have little control over the direction the player is facing in the real world.
For platforms that do offer spatial tracking, our origin point depends very much on the system. For OpenVR, our origin point is usually the center of the tracking space, on the ground. For other platforms, it's often the location of the tracking camera.
This method allows you to center your tracker on the location of the HMD. It will take the current location of the HMD and use that to adjust all your tracking data; in essence, realigning the real world to your player's current position in the game world.
For this method to produce usable results, tracking information must be available. This often takes a few frames after starting your game.
You should call this method after a few seconds have passed. For instance, when the user requests a realignment of the display holding a designated button on a controller for a short period of time, or when implementing a teleport mechanism.
Returns the primary interface's transformation.
Registers an object.
Clears our current primary interface if it is set to the provided interface.
Returns the number of interfaces currently registered with the AR/VR server. If your project supports multiple AR/VR platforms, you can look through the available interface, and either present the user with a selection or simply try to initialize each interface and use the first one that returns true.
Removes this interface.
Returns the interface registered at a given index in our list of interfaces.
Returns a list of available interfaces the ID and name of each interface.
Finds an interface by its name. For instance, if your project uses capabilities of an AR/VR platform, you can find the interface for that platform by name and initialize it.
Returns the number of trackers currently registered.
Returns the positional tracker at the given ID.
Registers a new that tracks a spatial location in real space.
Removes this positional tracker.
Returns the absolute timestamp (in μs) of the last process callback. The value comes from an internal call to .
Returns the absolute timestamp (in μs) of the last commit of the AR/VR eyes to . The value comes from an internal call to .
Returns the duration (in μs) of the last frame. This is computed as the difference between and when committing.
A* (A star) is a computer algorithm that is widely used in pathfinding and graph traversal, the process of plotting short paths among vertices (points), passing through a given set of edges (segments). It enjoys widespread use due to its performance and accuracy. Godot's A* implementation uses points in three-dimensional space and Euclidean distances by default.
You must add points manually with and create segments manually with . Then you can test if there is a path between two points with the function, get a path containing indices by , or one containing actual coordinates with .
It is also possible to use non-Euclidean distances. To do so, create a class that extends AStar and override methods and . Both take two indices and return a length, as is shown in the following example.
class MyAStar:
extends AStar
func _compute_cost(u, v):
return abs(u - v)
func _estimate_cost(u, v):
return min(0, abs(u - v) - 1)
should return a lower bound of the distance, i.e. _estimate_cost(u, v) <= _compute_cost(u, v). This serves as a hint to the algorithm because the custom _compute_cost might be computation-heavy. If this is not the case, make return the same value as to provide the algorithm with the most accurate information.
If the default and methods are used, or if the supplied method returns a lower bound of the cost, then the paths returned by A* will be the lowest-cost paths. Here, the cost of a path equals the sum of the results of all segments in the path multiplied by the weight_scales of the endpoints of the respective segments. If the default methods are used and the weight_scales of all points are set to 1.0, then this equals the sum of Euclidean distances of all segments in the path.
Called when computing the cost between two connected points.
Note that this function is hidden in the default AStar class.
Called when estimating the cost between a point and the path's ending point.
Note that this function is hidden in the default AStar class.
Returns the next available point ID with no point associated to it.
Adds a new point at the given position with the given identifier. The id must be 0 or larger, and the weight_scale must be 0.0 or greater.
The weight_scale is multiplied by the result of when determining the overall cost of traveling across a segment from a neighboring point to this point. Thus, all else being equal, the algorithm prefers points with lower weight_scales to form a path.
var astar = AStar.new()
astar.add_point(1, Vector3(1, 0, 0), 4) # Adds the point (1, 0, 0) with weight_scale 4 and id 1
If there already exists a point for the given id, its position and weight scale are updated to the given values.
Returns the position of the point associated with the given id.
Sets the position for the point with the given id.
Returns the weight scale of the point associated with the given id.
Sets the weight_scale for the point with the given id. The weight_scale is multiplied by the result of when determining the overall cost of traveling across a segment from a neighboring point to this point.
Removes the point associated with the given id from the points pool.
Returns whether a point associated with the given id exists.
Returns an array with the IDs of the points that form the connection with the given point.
var astar = AStar.new()
astar.add_point(1, Vector3(0, 0, 0))
astar.add_point(2, Vector3(0, 1, 0))
astar.add_point(3, Vector3(1, 1, 0))
astar.add_point(4, Vector3(2, 0, 0))
astar.connect_points(1, 2, true)
astar.connect_points(1, 3, true)
var neighbors = astar.get_point_connections(1) # Returns [2, 3]
Returns an array of all points.
Disables or enables the specified point for pathfinding. Useful for making a temporary obstacle.
Returns whether a point is disabled or not for pathfinding. By default, all points are enabled.
Creates a segment between the given points. If bidirectional is false, only movement from id to to_id is allowed, not the reverse direction.
var astar = AStar.new()
astar.add_point(1, Vector3(1, 1, 0))
astar.add_point(2, Vector3(0, 5, 0))
astar.connect_points(1, 2, false)
Deletes the segment between the given points. If bidirectional is false, only movement from id to to_id is prevented, and a unidirectional segment possibly remains.
Returns whether the two given points are directly connected by a segment. If bidirectional is false, returns whether movement from id to to_id is possible through this segment.
Returns the number of points currently in the points pool.
Returns the capacity of the structure backing the points, useful in conjunction with reserve_space.
Reserves space internally for num_nodes points, useful if you're adding a known large number of points at once, for a grid for instance. New capacity must be greater or equals to old capacity.
Clears all the points and segments.
Returns the ID of the closest point to to_position, optionally taking disabled points into account. Returns -1 if there are no points in the points pool.
Note: If several points are the closest to to_position, the one with the smallest ID will be returned, ensuring a deterministic result.
Returns the closest position to to_position that resides inside a segment between two connected points.
var astar = AStar.new()
astar.add_point(1, Vector3(0, 0, 0))
astar.add_point(2, Vector3(0, 5, 0))
astar.connect_points(1, 2)
var res = astar.get_closest_position_in_segment(Vector3(3, 3, 0)) # Returns (0, 3, 0)
The result is in the segment that goes from y = 0 to y = 5. It's the closest position in the segment to the given point.
Returns an array with the points that are in the path found by AStar between the given points. The array is ordered from the starting point to the ending point of the path.
Note: This method is not thread-safe. If called from a , it will return an empty and will print an error message.
Returns an array with the IDs of the points that form the path found by AStar between the given points. The array is ordered from the starting point to the ending point of the path.
var astar = AStar.new()
astar.add_point(1, Vector3(0, 0, 0))
astar.add_point(2, Vector3(0, 1, 0), 1) # Default weight is 1
astar.add_point(3, Vector3(1, 1, 0))
astar.add_point(4, Vector3(2, 0, 0))
astar.connect_points(1, 2, false)
astar.connect_points(2, 3, false)
astar.connect_points(4, 3, false)
astar.connect_points(1, 4, false)
var res = astar.get_id_path(1, 3) # Returns [1, 2, 3]
If you change the 2nd point's weight to 3, then the result will be [1, 4, 3] instead, because now even though the distance is longer, it's "easier" to get through point 4 than through point 2.
This is a wrapper for the class which uses 2D vectors instead of 3D vectors.
Called when computing the cost between two connected points.
Note that this function is hidden in the default AStar2D class.
Called when estimating the cost between a point and the path's ending point.
Note that this function is hidden in the default AStar2D class.
Returns the next available point ID with no point associated to it.
Adds a new point at the given position with the given identifier. The id must be 0 or larger, and the weight_scale must be 0.0 or greater.
The weight_scale is multiplied by the result of when determining the overall cost of traveling across a segment from a neighboring point to this point. Thus, all else being equal, the algorithm prefers points with lower weight_scales to form a path.
var astar = AStar2D.new()
astar.add_point(1, Vector2(1, 0), 4) # Adds the point (1, 0) with weight_scale 4 and id 1
If there already exists a point for the given id, its position and weight scale are updated to the given values.
Returns the position of the point associated with the given id.
Sets the position for the point with the given id.
Returns the weight scale of the point associated with the given id.
Sets the weight_scale for the point with the given id. The weight_scale is multiplied by the result of when determining the overall cost of traveling across a segment from a neighboring point to this point.
Removes the point associated with the given id from the points pool.
Returns whether a point associated with the given id exists.
Returns an array with the IDs of the points that form the connection with the given point.
var astar = AStar2D.new()
astar.add_point(1, Vector2(0, 0))
astar.add_point(2, Vector2(0, 1))
astar.add_point(3, Vector2(1, 1))
astar.add_point(4, Vector2(2, 0))
astar.connect_points(1, 2, true)
astar.connect_points(1, 3, true)
var neighbors = astar.get_point_connections(1) # Returns [2, 3]
Returns an array of all points.
Disables or enables the specified point for pathfinding. Useful for making a temporary obstacle.
Returns whether a point is disabled or not for pathfinding. By default, all points are enabled.
Creates a segment between the given points. If bidirectional is false, only movement from id to to_id is allowed, not the reverse direction.
var astar = AStar2D.new()
astar.add_point(1, Vector2(1, 1))
astar.add_point(2, Vector2(0, 5))
astar.connect_points(1, 2, false)
Deletes the segment between the given points. If bidirectional is false, only movement from id to to_id is prevented, and a unidirectional segment possibly remains.
Returns whether there is a connection/segment between the given points. If bidirectional is false, returns whether movement from id to to_id is possible through this segment.
Returns the number of points currently in the points pool.
Returns the capacity of the structure backing the points, useful in conjunction with reserve_space.
Reserves space internally for num_nodes points, useful if you're adding a known large number of points at once, for a grid for instance. New capacity must be greater or equals to old capacity.
Clears all the points and segments.
Returns the ID of the closest point to to_position, optionally taking disabled points into account. Returns -1 if there are no points in the points pool.
Note: If several points are the closest to to_position, the one with the smallest ID will be returned, ensuring a deterministic result.
Returns the closest position to to_position that resides inside a segment between two connected points.
var astar = AStar2D.new()
astar.add_point(1, Vector2(0, 0))
astar.add_point(2, Vector2(0, 5))
astar.connect_points(1, 2)
var res = astar.get_closest_position_in_segment(Vector2(3, 3)) # Returns (0, 3)
The result is in the segment that goes from y = 0 to y = 5. It's the closest position in the segment to the given point.
Returns an array with the points that are in the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path.
Note: This method is not thread-safe. If called from a , it will return an empty and will print an error message.
Returns an array with the IDs of the points that form the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path.
var astar = AStar2D.new()
astar.add_point(1, Vector2(0, 0))
astar.add_point(2, Vector2(0, 1), 1) # Default weight is 1
astar.add_point(3, Vector2(1, 1))
astar.add_point(4, Vector2(2, 0))
astar.connect_points(1, 2, false)
astar.connect_points(2, 3, false)
astar.connect_points(4, 3, false)
astar.connect_points(1, 4, false)
var res = astar.get_id_path(1, 3) # Returns [1, 2, 3]
If you change the 2nd point's weight to 3, then the result will be [1, 4, 3] instead, because now even though the distance is longer, it's "easier" to get through point 4 than through point 2.
This dialog is useful for small notifications to the user about an event. It can only be accepted or closed, with the same result.
The text displayed by the dialog.
If true, the dialog is hidden when the OK button is pressed. You can set it to false if you want to do e.g. input validation when receiving the confirmed signal, and handle hiding the dialog in your own logic.
Note: Some nodes derived from this class can have a different default value, and potentially their own built-in logic overriding this setting. For example defaults to false, and has its own input validation code that is called when you press OK, which eventually hides the dialog if the input is valid. As such, this property can't be used in to disable hiding the dialog when pressing OK.
Sets autowrapping for the text in the dialog.
Returns the OK instance.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Returns the label used for built-in text.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Adds a button with label text and a custom action to the dialog and returns the created button. action will be passed to the custom_action signal when pressed.
If true, right will place the button to the right of any sibling buttons.
You can use method to remove a button created with this method from the dialog.
Adds a button with label name and a cancel action to the dialog and returns the created button.
You can use method to remove a button created with this method from the dialog.
Removes the button from the dialog. Does NOT free the button. The button must be a added with or method. After removal, pressing the button will no longer emit this dialog's custom_action signal or cancel this dialog.
Registers a in the dialog. When the enter key is pressed, the dialog will be accepted.
is similar to the node, except it carries multiple textures as animation frames. Animations are created using a resource, which allows you to import image files (or a folder containing said files) to provide the animation frames for the sprite. The resource can be configured in the editor via the SpriteFrames bottom panel.
Note: You can associate a set of normal or specular maps by creating additional resources with a _normal or _specular suffix. For example, having 3 resources run, run_normal, and run_specular will make it so the run animation uses normal and specular maps.
The resource containing the animation(s). Allows you the option to load, edit, clear, make unique and save the states of the resource.
The current animation from the resource. If this value changes, the frame counter is reset.
The displayed animation frame's index.
The animation speed is multiplied by this value.
If true, the is currently playing.
If true, texture will be centered.
The texture's drawing offset.
If true, texture is flipped horizontally.
If true, texture is flipped vertically.
Plays the animation named anim. If no anim is provided, the current animation is played. If backwards is true, the animation will be played in reverse.
Stops the current animation (does not reset the frame counter).
Animations are created using a resource, which can be configured in the editor via the SpriteFrames panel.
The resource containing the animation(s).
The current animation from the frames resource. If this value changes, the frame counter is reset.
The displayed animation frame's index.
If true, the is currently playing.
Plays the animation named anim. If no anim is provided, the current animation is played.
Stops the current animation (does not reset the frame counter).
Returns true if an animation is currently being played.
is a resource format for frame-based animations, where multiple textures can be chained automatically with a predefined delay for each frame. Unlike or , it isn't a , but has the advantage of being usable anywhere a resource can be used, e.g. in a .
The playback of the animation is controlled by the property as well as each frame's optional delay (see ). The animation loops, i.e. it will restart at frame 0 automatically after playing the last frame.
currently requires all frame textures to have the same size, otherwise the bigger ones will be cropped to match the smallest one.
Note: AnimatedTexture doesn't support using s. Each frame needs to be a separate .
The maximum number of frames supported by . If you need more frames in your animation, use or .
Number of frames to use in the animation. While you can create the frames independently with , you need to set this value for the animation to take new frames into account. The maximum number of frames is .
Sets the currently visible frame of the texture.
If true, the animation will pause where it currently is (i.e. at ). The animation will continue from where it was paused when changing this property to false.
If true, the animation will only play once and will not loop back to the first frame after reaching the end. Note that reaching the end will not set to true.
Animation speed in frames per second. This value defines the default time interval between two frames of the animation, and thus the overall duration of the animation loop based on the property. A value of 0 means no predefined number of frames per second, the animation will play according to each frame's frame delay (see ).
For example, an animation with 8 frames, no frame delay and a fps value of 2 will run for 4 seconds, with each frame lasting 0.5 seconds.
Assigns a to the given frame. Frame IDs start at 0, so the first frame has ID 0, and the last frame of the animation has ID - 1.
You can define any number of textures up to , but keep in mind that only frames from 0 to - 1 will be part of the animation.
Returns the given frame's .
Sets an additional delay (in seconds) between this frame and the next one, that will be added to the time interval defined by . By default, frames have no delay defined. If a delay value is defined, the final time interval between this frame and the next will be 1.0 / fps + delay.
For example, for an animation with 3 frames, 2 FPS and a frame delay on the second frame of 1.2, the resulting playback will be:
Frame 0: 0.5 s (1 / fps)
Frame 1: 1.7 s (1 / fps + 1.2)
Frame 2: 0.5 s (1 / fps)
Total duration: 2.7 s
Returns the given frame's delay value.
An Animation resource contains data used to animate everything in the engine. Animations are divided into tracks, and each track must be linked to a node. The state of that node can be changed through time, by adding timed keys (events) to the track.
# This creates an animation that makes the node "Enemy" move to the right by
# 100 pixels in 0.5 seconds.
var animation = Animation.new()
var track_index = animation.add_track(Animation.TYPE_VALUE)
animation.track_set_path(track_index, "Enemy:position:x")
animation.track_insert_key(track_index, 0.0, 0)
animation.track_insert_key(track_index, 0.5, 100)
Animations are just data containers, and must be added to nodes such as an or to be played back. Animation tracks have different types, each with its own set of dedicated methods. Check to see available types.
Value tracks set values in node properties, but only those which can be Interpolated.
Transform tracks are used to change node local transforms or skeleton pose bones. Transitions are interpolated.
Method tracks call functions with given arguments per key.
Bezier tracks are used to interpolate a value using custom curves. They can also be used to animate sub-properties of vectors and colors (e.g. alpha value of a ).
Audio tracks are used to play an audio stream with either type of . The stream can be trimmed and previewed in the animation.
Animation tracks play animations in other nodes.
Update between keyframes.
Update at the keyframes and hold the value.
Update at the keyframes.
Same as linear interpolation, but also interpolates from the current value (i.e. dynamically at runtime) if the first key isn't at 0 seconds.
No interpolation (nearest value).
Linear interpolation.
Cubic interpolation.
The total length of the animation (in seconds).
Note: Length is not delimited by the last key, as this one may be before or after the end to ensure correct interpolation and looping.
A flag indicating that the animation must loop. This is used for correct interpolation of animation cycles, and for hinting the player that it must restart the animation.
The animation step value.
Adds a track to the Animation.
Removes a track by specifying the track index.
Returns the amount of tracks in the animation.
Gets the type of a track.
Gets the path of a track. For more information on the path format, see .
Sets the path of a track. Paths must be valid scene-tree paths to a node and must be specified starting from the parent node of the node that will reproduce the animation. Tracks that control properties or bones must append their name after the path, separated by ":".
For example, "character/skeleton:ankle" or "character/mesh:transform/local".
Returns the index of the specified track. If the track is not found, return -1.
Moves a track up.
Moves a track down.
Changes the index position of track idx to the one defined in to_idx.
Swaps the track idx's index position with the track with_idx.
Sets the given track as imported or not.
Returns true if the given track is imported. Else, return false.
Enables/disables the given track. Tracks are enabled by default.
Returns true if the track at index idx is enabled.
Insert a transform key for a transform track.
Insert a generic key in a given track.
Removes a key by index in a given track.
Removes a key by position (seconds) in a given track.
Sets the value of an existing key.
Sets the transition curve (easing) for a specific key (see the built-in math function @GDScript.ease).
Sets the time of an existing key.
Returns the transition curve (easing) for a specific key (see the built-in math function @GDScript.ease).
Returns the amount of keys in a given track.
Returns the value of a given key in a given track.
Returns the time at which the key is located.
Finds the key index by time in a given track. Optionally, only find it if the exact time is given.
Sets the interpolation type of a given track.
Returns the interpolation type of a given track.
If true, the track at idx wraps the interpolation loop.
Returns true if the track at idx wraps the interpolation loop. New tracks wrap the interpolation loop by default.
Returns the interpolated value of a transform track at a given time (in seconds). An array consisting of 3 elements: position (), rotation () and scale ().
Sets the update mode (see ) of a value track.
Returns the update mode of a value track.
Returns all the key indices of a value track, given a position and delta time.
Returns the interpolated value at the given time (in seconds). The track_idx must be the index of a value track.
Returns all the key indices of a method track, given a position and delta time.
Returns the method name of a method track.
Returns the arguments values to be called on a method track for a given key in a given track.
Inserts a Bezier Track key at the given time in seconds. The track_idx must be the index of a Bezier Track.
in_handle is the left-side weight of the added Bezier curve point, out_handle is the right-side one, while value is the actual value at this point.
If the parameter is null, then the default value is new Vector2(0, 0)
If the parameter is null, then the default value is new Vector2(0, 0)
Sets the value of the key identified by key_idx to the given value. The track_idx must be the index of a Bezier Track.
Sets the in handle of the key identified by key_idx to value in_handle. The track_idx must be the index of a Bezier Track.
Sets the out handle of the key identified by key_idx to value out_handle. The track_idx must be the index of a Bezier Track.
Returns the value of the key identified by key_idx. The track_idx must be the index of a Bezier Track.
Returns the in handle of the key identified by key_idx. The track_idx must be the index of a Bezier Track.
Returns the out handle of the key identified by key_idx. The track_idx must be the index of a Bezier Track.
Returns the interpolated value at the given time (in seconds). The track_idx must be the index of a Bezier Track.
Inserts an Audio Track key at the given time in seconds. The track_idx must be the index of an Audio Track.
stream is the resource to play. start_offset is the number of seconds cut off at the beginning of the audio stream, while end_offset is at the ending.
Sets the stream of the key identified by key_idx to value stream. The track_idx must be the index of an Audio Track.
Sets the start offset of the key identified by key_idx to value offset. The track_idx must be the index of an Audio Track.
Sets the end offset of the key identified by key_idx to value offset. The track_idx must be the index of an Audio Track.
Returns the audio stream of the key identified by key_idx. The track_idx must be the index of an Audio Track.
Returns the start offset of the key identified by key_idx. The track_idx must be the index of an Audio Track.
Start offset is the number of seconds cut off at the beginning of the audio stream.
Returns the end offset of the key identified by key_idx. The track_idx must be the index of an Audio Track.
End offset is the number of seconds cut off at the ending of the audio stream.
Inserts a key with value animation at the given time (in seconds). The track_idx must be the index of an Animation Track.
Sets the key identified by key_idx to value animation. The track_idx must be the index of an Animation Track.
Returns the animation name at the key identified by key_idx. The track_idx must be the index of an Animation Track.
Clear the animation (clear all tracks and reset all).
Adds a new track that is a copy of the given track from to_animation.
Base resource for nodes. In general, it's not used directly, but you can create custom ones with custom blending formulas.
Inherit this when creating nodes mainly for use in , otherwise should be used instead.
Do not use filtering.
Paths matching the filter will be allowed to pass.
Paths matching the filter will be discarded.
Paths matching the filter will be blended (by the blend value).
If true, filtering is enabled.
When inheriting from , implement this virtual method to override the text caption for this node.
When inheriting from , implement this virtual method to return a child node by its name.
When inheriting from , implement this virtual method to return all children nodes in order as a name: node dictionary.
When inheriting from , implement this virtual method to return the default value of parameter "name". Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees.
When inheriting from , implement this virtual method to return a list of the properties on this node. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees. Format is similar to .
When inheriting from , implement this virtual method to return whether the blend tree editor should display filter editing on this node.
When inheriting from , implement this virtual method to run some code when this node is processed. The time parameter is a relative delta, unless seek is true, in which case it is absolute.
Here, call the , or functions. You can also use and to modify local memory.
This function should return the time left for the current animation to finish (if unsure, pass the value from the main blend being called).
Amount of inputs in this node, only useful for nodes that go into .
Gets the name of an input by index.
Adds an input to the node. This is only useful for nodes created for use in an .
Removes an input, call this only when inactive.
Adds or removes a path for the filter.
Returns whether the given path is filtered.
Blend an animation by blend amount (name must be valid in the linked ). A time and delta may be passed, as well as whether seek happened.
Blend another animation node (in case this node contains children animation nodes). This function is only useful if you inherit from instead, else editors will not display your node for addition.
Blend an input. This is only useful for nodes created for an . The time parameter is a relative delta, unless seek is true, in which case it is absolute. A filter mode may be optionally passed (see for options).
Sets a custom parameter. These are used as local memory, because resources can be reused across the tree or scenes.
Gets the value of a parameter. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees.
A resource to add to an . Blends two animations additively based on an amount value in the [0.0, 1.0] range.
If true, sets the optimization to false when calling , forcing the blended animations to update every frame.
A resource to add to an . Blends two animations together additively out of three based on a value in the [-1.0, 1.0] range.
This node has three inputs:
- The base animation to add to
- A -add animation to blend with when the blend amount is in the [-1.0, 0.0] range.
- A +add animation to blend with when the blend amount is in the [0.0, 1.0] range
If true, sets the optimization to false when calling , forcing the blended animations to update every frame.
A resource to add to an . Only features one output set using the property. Use it as an input for that blend animations together.
Animation to use as an output. It is one of the animations provided by .
A resource to add to an . Blends two animations linearly based on an amount value in the [0.0, 1.0] range.
If true, sets the optimization to false when calling , forcing the blended animations to update every frame.
A resource to add to an . Blends two animations together linearly out of three based on a value in the [-1.0, 1.0] range.
This node has three inputs:
- The base animation
- A -blend animation to blend with when the blend amount is in the [-1.0, 0.0] range.
- A +blend animation to blend with when the blend amount is in the [0.0, 1.0] range
If true, sets the optimization to false when calling , forcing the blended animations to update every frame.
A resource to add to an .
This is a virtual axis on which you can add any type of using .
Outputs the linear blend of the two s closest to the node's current value.
You can set the extents of the axis using the and .
The blend space's axis's lower limit for the points' position. See .
The blend space's axis's upper limit for the points' position. See .
Position increment to snap to when moving a point on the axis.
Label of the virtual axis of the blend space.
Adds a new point that represents a node on the virtual axis at a given position set by pos. You can insert it at a specific index using the at_index argument. If you use the default value for at_index, the point is inserted at the end of the blend points array.
Updates the position of the point at index point on the blend axis.
Returns the position of the point at index point.
Changes the referenced by the point at index point.
Returns the referenced by the point at index point.
Removes the point at index point from the blend axis.
Returns the number of points on the blend axis.
A resource to add to an .
This node allows you to blend linearly between three animations using a weight.
You can add vertices to the blend space with and automatically triangulate it by setting to true. Otherwise, use and to create up the blend space by hand.
The interpolation between animations is linear.
The blend space plays the animation of the node the blending position is closest to. Useful for frame-by-frame 2D animations.
Similar to , but starts the new animation at the last animation's playback position.
If true, the blend space is triangulated automatically. The mesh updates every time you add or remove points with and .
The blend space's X and Y axes' lower limit for the points' position. See .
The blend space's X and Y axes' upper limit for the points' position. See .
Position increment to snap to when moving a point.
Name of the blend space's X axis.
Name of the blend space's Y axis.
Controls the interpolation between animations. See constants.
Adds a new point that represents a node at the position set by pos. You can insert it at a specific index using the at_index argument. If you use the default value for at_index, the point is inserted at the end of the blend points array.
Updates the position of the point at index point on the blend axis.
Returns the position of the point at index point.
Changes the referenced by the point at index point.
Returns the referenced by the point at index point.
Removes the point at index point from the blend space.
Returns the number of points in the blend space.
Creates a new triangle using three points x, y, and z. Triangles can overlap. You can insert the triangle at a specific index using the at_index argument. If you use the default value for at_index, the point is inserted at the end of the blend points array.
Returns the position of the point at index point in the triangle of index triangle.
Removes the triangle at index triangle from the blend space.
Returns the number of triangles in the blend space.
This node may contain a sub-tree of any other blend type nodes, such as , , , , etc. This is one of the most commonly used roots.
An node named output is created by default.
The connection was successful.
The input node is null.
The specified input port is out of range.
The output node is null.
Input and output nodes are the same.
The specified connection already exists.
The global offset of all sub-nodes.
Adds an at the given position. The name is used to identify the created sub-node later.
If the parameter is null, then the default value is new Vector2(0, 0)
Returns the sub-node with the specified name.
Removes a sub-node.
Changes the name of a sub-node.
Returns true if a sub-node with specified name exists.
Connects the output of an as input for another , at the input port specified by input_index.
Disconnects the node connected to the specified input.
Modifies the position of a sub-node.
Returns the position of the sub-node with the specified name.
A resource to add to an . This node will execute a sub-animation and return once it finishes. Blend times for fading in and out can be customized, as well as filters.
If true, the sub-animation will restart automatically after finishing.
The delay after which the automatic restart is triggered, in seconds.
If is true, a random additional delay (in seconds) between 0 and this value will be added to .
Contains multiple nodes representing animation states, connected in a graph. Node transitions can be configured to happen automatically or via code, using a shortest-path algorithm. Retrieve the object from the node to control it programmatically.
Example:
var state_machine = $AnimationTree.get("parameters/playback")
state_machine.travel("some_state")
Adds a new node to the graph. The position is used for display in the editor.
If the parameter is null, then the default value is new Vector2(0, 0)
Replaces the node and keeps its transitions unchanged.
Returns the animation node with the given name.
Deletes the given node from the graph.
Renames the given node.
Returns true if the graph contains the given node.
Returns the given animation node's name.
Sets the node's coordinates. Used for display in the editor.
Returns the given node's coordinates. Used for display in the editor.
Returns true if there is a transition between the given nodes.
Adds a transition between the given nodes.
Returns the given transition.
Returns the given transition's start node.
Returns the given transition's end node.
Returns the number of connections in the graph.
Deletes the given transition by index.
Deletes the transition between the two specified nodes.
Sets the given node as the graph start point.
Returns the graph's end node.
Sets the given node as the graph end point.
Returns the graph's end node.
Sets the draw offset of the graph. Used for display in the editor.
Returns the draw offset of the graph. Used for display in the editor.
Allows control of state machines created with . Retrieve with $AnimationTree.get("parameters/playback").
Example:
var state_machine = $AnimationTree.get("parameters/playback")
state_machine.travel("some_state")
Transitions from the current state to another one, following the shortest path.
Starts playing the given animation.
Stops the currently playing animation.
Returns true if an animation is playing.
Returns the currently playing animation state.
Returns the playback position within the current animation state.
Returns the current travel path as computed internally by the A* algorithm.
Switch to the next state immediately. The current state will end and blend into the beginning of the new one.
Switch to the next state immediately, but will seek the new state to the playback position of the old state.
Wait for the current state playback to end, then switch to the beginning of the next state animation.
The transition type.
Turn on the transition automatically when this state is reached. This works best with .
Turn on auto advance when this condition is set. The provided name will become a boolean parameter on the that can be controlled from code (see Using AnimationTree). For example, if is an and is set to "idle":
$animation_tree["parameters/conditions/idle"] = is_on_floor and (linear_velocity.x == 0)
The time to cross-fade between this state and the next.
Lower priority transitions are preferred when travelling through the tree via or .
Don't use this transition during or .
Allows scaling the speed of the animation (or reversing it) in any children nodes. Setting it to 0 will pause the animation.
This node can be used to cause a seek command to happen to any sub-children of the animation graph. Use this node type to play an from the start or a certain playback position inside the . After setting the time and changing the animation playback, the seek node automatically goes into sleep mode on the next process frame by setting its seek_position value to -1.0.
# Play child animation from the start.
animation_tree.set("parameters/Seek/seek_position", 0.0)
# Alternative syntax (same result as above).
animation_tree["parameters/Seek/seek_position"] = 0.0
# Play child animation from 12 second timestamp.
animation_tree.set("parameters/Seek/seek_position", 12.0)
# Alternative syntax (same result as above).
animation_tree["parameters/Seek/seek_position"] = 12.0
Simple state machine for cases which don't require a more advanced . Animations can be connected to the inputs and transition times can be specified.
The number of available input ports for this node.
Cross-fading time (in seconds) between each animation connected to the inputs.
An animation player is used for general-purpose playback of resources. It contains a dictionary of animations (referenced by name) and custom blend times between their transitions. Additionally, animations can be played and blended in different channels.
is more suited than for animations where you know the final values in advance. For example, fading a screen in and out is more easily done with an node thanks to the animation tools provided by the editor. That particular example can also be implemented with a node, but it requires doing everything by code.
Updating the target properties of animations occurs at process time.
Process animation during the physics process. This is especially useful when animating physics bodies.
Process animation during the idle process.
Do not process animation. Use to process the animation manually.
Batch method calls during the animation process, then do the calls after events are processed. This avoids bugs involving deleting nodes or modifying the AnimationPlayer while playing.
Make method calls immediately when reached in the animation.
The node from which node path references will travel.
The name of the currently playing animation. If no animation is playing, the property's value is an empty string. Changing this value does not restart the animation. See for more information on playing animations.
Note: While this property appears in the inspector, it's not meant to be edited, and it's not saved in the scene. This property is mainly used to get the currently playing animation, and internally for animation playback tracks. For more information, see .
If playing, the current animation; otherwise, the animation last played. When set, would change the animation, but would not play it unless currently playing. See also .
The name of the animation to play when the scene loads.
This is used by the editor. If set to true, the scene will be saved with the effects of the reset animation applied (as if it had been seeked to time 0), then reverted after saving.
In other words, the saved scene file will contain the "default pose", as defined by the reset animation, if any, with the editor keeping the values that the nodes had before saving.
The length (in seconds) of the currently being played animation.
The position (in seconds) of the currently playing animation.
The process notification in which to update animations.
The default time in which to blend animations. Ranges from 0 to 4096 with 0.01 precision.
If true, updates animations in response to process-related notifications.
The speed scaling ratio. For instance, if this value is 1, then the animation plays at normal speed. If it's 0.5, then it plays at half speed. If it's 2, then it plays at double speed.
The call mode to use for Call Method tracks.
Adds animation to the player accessible with the key name.
Removes the animation with key name.
Renames an existing animation with key name to newname.
Returns true if the stores an with key name.
Returns the with the key name. If the animation does not exist, null is returned and an error is logged.
Returns the list of stored animation names.
Triggers the anim_to animation when the anim_from animation completes.
Returns the name of the next animation in the queue.
Specifies a blend time (in seconds) between two animations, referenced by their names.
Gets the blend time (in seconds) between two animations, referenced by their names.
Plays the animation with key name. Custom blend times and speed can be set. If custom_speed is negative and from_end is true, the animation will play backwards (which is equivalent to calling ).
The keeps track of its current or last played animation with . If this method is called with that same animation name, or with no name parameter, the assigned animation will resume playing if it was paused, or restart if it was stopped (see for both pause and stop). If the animation was already playing, it will keep playing.
Note: The animation will be updated the next time the is processed. If other variables are updated at the same time this is called, they may be updated too early. To perform the update immediately, call advance(0).
Plays the animation with key name in reverse.
This method is a shorthand for with custom_speed = -1.0 and from_end = true, so see its description for more information.
Stops or pauses the currently playing animation. If reset is true, the animation position is reset to 0 and the playback speed is reset to 1.0.
If reset is false, the will be kept and calling or without arguments or with the same animation name as will resume the animation.
Returns true if playing an animation.
Queues an animation for playback once the current one is done.
Note: If a looped animation is currently playing, the queued animation will never play unless the looped animation is stopped somehow.
Returns a list of the animation names that are currently queued to play.
Clears all queued, unplayed animations.
Gets the actual playing speed of current animation or 0 if not playing. This speed is the property multiplied by custom_speed argument specified when calling the method.
Returns the name of animation or an empty string if not found.
caches animated nodes. It may not notice if a node disappears; forces it to update the cache again.
Seeks the animation to the seconds point in time (in seconds). If update is true, the animation updates too, otherwise it updates at process time. Events between the current frame and seconds are skipped.
Note: Seeking to the end of the animation doesn't emit animation_finished. If you want to skip animation and emit the signal, use .
Shifts position in the animation timeline and immediately updates the animation. delta is the time in seconds to shift. Events between the current frame and delta are handled.
A node to be used for advanced animation transitions in an .
Note: When linked with an , several properties and methods of the corresponding will not function as expected. Playback and transitions should be handled using only the and its constituent (s). The node should be used solely for adding, deleting, and editing animations.
The animations will progress during the physics frame (i.e. ).
The animations will progress during the idle frame (i.e. ).
The animations will only progress manually (see ).
The root animation node of this . See .
The path to the used for animating.
If true, the will be processing.
The process mode of this . See for available modes.
The path to the Animation track used for root motion. Paths must be valid scene-tree paths to a node, and must be specified starting from the parent node of the node that will reproduce the animation. To specify a track that controls properties or bones, append its name after the path, separated by ":". For example, "character/skeleton:ankle" or "character/mesh:transform/local".
If the track has type , the transformation will be cancelled visually, and the animation will appear to stay in place. See also and RootMotionView.
Retrieve the motion of the as a that can be used elsewhere. If is not a path to a track of type , returns an identity transformation. See also and RootMotionView.
Manually advance the animations by the specified time (in seconds).
Deprecated. A node graph tool for blending multiple animations bound to an . Especially useful for animating characters or other skeleton-based rigs. It can combine several animations to form a desired pose.
It takes s from an node and mixes them depending on the graph.
See for a more full-featured replacement of this node.
Process animation during the physics process. This is especially useful when animating physics bodies.
Process animation during the idle process.
Output node.
Animation node.
OneShot node.
Mix node.
Blend2 node.
Blend3 node.
Blend4 node.
TimeScale node.
TimeSeek node.
Transition node.
The thread in which to update animations.
The path to the from which this binds animations to animation nodes.
Once set, nodes can be added to the .
The node from which to relatively access other nodes.
It accesses the bones, so it should point to the same node the would point its Root Node at.
If true, the is able to play animations.
Adds a type node to the graph with name id.
Check if a node exists (by name).
Renames a node in the graph.
Gets the node type, will return from enum.
Returns the input count for a given node. Different types of nodes have different amount of inputs.
Returns the input source for a given node input.
Binds a new from the to the 's animation node with name id.
Returns the 's bound to the 's animation node with name id.
Binds the named source from to the animation node id. Recalculates caches.
Returns the name of the 's bound to this animation node.
Returns the absolute playback timestamp of the animation node with name id.
If enable is true, the animation node with ID id turns off the track modifying the property at path. The modified node's children continue to animate.
Sets the fade in time of a OneShot node given its name and value in seconds.
Returns the fade in time of a OneShot node given its name.
Sets the fade out time of a OneShot node given its name and value in seconds.
Returns the fade out time of a OneShot node given its name.
Sets the autorestart property of a OneShot node given its name and value.
Sets the autorestart delay of a OneShot node given its name and value in seconds.
Sets the autorestart random delay of a OneShot node given its name and value in seconds.
Returns whether a OneShot node will auto restart given its name.
Returns the autostart delay of a OneShot node given its name.
Returns the autostart random delay of a OneShot node given its name.
Starts a OneShot node given its name.
Stops the OneShot node with name id.
Returns whether a OneShot node is active given its name.
If enable is true, the OneShot node with ID id turns off the track modifying the property at path. The modified node's children continue to animate.
Sets the mix amount of a Mix node given its name and value.
A Mix node adds input b to input a by the amount given by ratio.
Returns the mix amount of a Mix node given its name.
Sets the blend amount of a Blend2 node given its name and value.
A Blend2 node blends two animations (A and B) with the amount between 0 and 1.
At 0, output is input A. Towards 1, the influence of A gets lessened, the influence of B gets raised. At 1, output is input B.
Returns the blend amount of a Blend2 node given its name.
If enable is true, the Blend2 node with name id turns off the track modifying the property at path. The modified node's children continue to animate.
Sets the blend amount of a Blend3 node given its name and value.
A Blend3 Node blends three animations (A, B-, B+) with the amount between -1 and 1.
At -1, output is input B-. From -1 to 0, the influence of B- gets lessened, the influence of A gets raised and the influence of B+ is 0. At 0, output is input A. From 0 to 1, the influence of A gets lessened, the influence of B+ gets raised and the influence of B+ is 0. At 1, output is input B+.
Returns the blend amount of a Blend3 node given its name.
Sets the blend amount of a Blend4 node given its name and value.
A Blend4 Node blends two pairs of animations.
The two pairs are blended like Blend2 and then added together.
Returns the blend amount of a Blend4 node given its name.
Sets the time scale of the TimeScale node with name id to scale.
The TimeScale node is used to speed s up if the scale is above 1 or slow them down if it is below 1.
If applied after a blend or mix, affects all input animations to that blend or mix.
Returns the time scale value of the TimeScale node with name id.
Sets the time seek value of the TimeSeek node with name id to seconds.
This functions as a seek in the or the blend or mix of s input in it.
Resizes the number of inputs available for the transition node with name id.
Returns the number of inputs for the transition node with name id. You can add inputs by right-clicking on the transition node.
Deletes the input at input_idx for the transition node with name id.
The transition node with name id advances to its next input automatically when the input at input_idx completes.
Returns true if the input at input_idx on the transition node with name id is set to automatically advance to the next input upon completion.
The transition node with name id sets its cross fade time to time_sec.
Returns the cross fade time for the transition node with name id.
The transition node with name id sets its current input at input_idx.
Returns the index of the currently evaluated input for the transition node with name id.
Sets the position of a node in the graph given its name and position.
Returns position of a node in the graph given its name.
Removes the animation node with name id.
Connects node id to dst_id at the specified input slot.
Returns whether node id and dst_id are connected at the specified slot.
Disconnects nodes connected to id at the specified input slot.
Returns a containing the name of all nodes.
Shifts position in the animation timeline. delta is the time in seconds to shift. Events between the current frame and delta are handled.
Resets this .
Manually recalculates the cache of track information generated from animation nodes. Needed when external sources modify the animation nodes' state.
3D area that detects nodes overlapping, entering, or exiting. Can also alter or override local physics parameters (gravity, damping) and route audio to a custom audio bus.
To give the area its shape, add a or a node as a direct child (or add multiple such nodes as direct children) of the area.
Warning: See (also called "trimesh") for a warning about possibly unexpected behavior when using that shape for an area.
This area does not affect gravity/damping.
This area adds its gravity/damping values to whatever has been calculated so far (in order).
This area adds its gravity/damping values to whatever has been calculated so far (in order), ignoring any lower priority areas.
This area replaces any gravity/damping, even the defaults, ignoring any lower priority areas.
This area replaces any gravity/damping calculated so far (in order), but keeps calculating the rest of the areas.
If true, the area detects bodies or areas entering and exiting it.
If true, other monitoring areas can detect this area.
The area's priority. Higher priority areas are processed first.
Override mode for gravity and damping calculations within this area. See for possible values.
If true, gravity is calculated from a point (set via ). See also .
The falloff factor for point gravity. The greater the value, the faster gravity decreases with distance.
The area's gravity vector (not normalized). If gravity is a point (see ), this will be the point of attraction.
The area's gravity intensity (in meters per second squared). This value multiplies the gravity vector. This is useful to alter the force of gravity without altering its direction.
The rate at which objects stop moving in this area. Represents the linear velocity lost per second.
See for more details about damping.
The rate at which objects stop spinning in this area. Represents the angular velocity lost per second.
See for more details about damping.
If true, the area's audio bus overrides the default audio bus.
The name of the area's audio bus.
If true, the area applies reverb to its associated audio.
The reverb bus name to use for this area's associated audio.
The degree to which this area applies reverb to its associated audio. Ranges from 0 to 1 with 0.1 precision.
The degree to which this area's reverb is a uniform effect. Ranges from 0 to 1 with 0.1 precision.
Returns a list of intersecting s. The overlapping body's must be part of this area's in order to be detected.
For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
Returns a list of intersecting s. The overlapping area's must be part of this area's in order to be detected.
For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
If true, the given physics body overlaps the Area.
Note: The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
The body argument can either be a or a instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body).
If true, the given area overlaps the Area.
Note: The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
2D area that detects nodes overlapping, entering, or exiting. Can also alter or override local physics parameters (gravity, damping) and route audio to a custom audio bus.
To give the area its shape, add a or a node as a direct child (or add multiple such nodes as direct children) of the area.
Warning: See for a warning about possibly unexpected behavior when using that shape for an area.
This area does not affect gravity/damping.
This area adds its gravity/damping values to whatever has been calculated so far (in order).
This area adds its gravity/damping values to whatever has been calculated so far (in order), ignoring any lower priority areas.
This area replaces any gravity/damping, even the defaults, ignoring any lower priority areas.
This area replaces any gravity/damping calculated so far (in order), but keeps calculating the rest of the areas.
If true, the area detects bodies or areas entering and exiting it.
If true, other monitoring areas can detect this area.
The area's priority. Higher priority areas are processed first.
Override mode for gravity and damping calculations within this area. See for possible values.
If true, gravity is calculated from a point (set via ). See also .
The falloff factor for point gravity. The greater the value, the faster gravity decreases with distance.
The area's gravity vector (not normalized). If gravity is a point (see ), this will be the point of attraction.
The area's gravity intensity (in pixels per second squared). This value multiplies the gravity vector. This is useful to alter the force of gravity without altering its direction.
The rate at which objects stop moving in this area. Represents the linear velocity lost per second.
See for more details about damping.
The rate at which objects stop spinning in this area. Represents the angular velocity lost per second.
See for more details about damping.
If true, the area's audio bus overrides the default audio bus.
The name of the area's audio bus.
Returns a list of intersecting s. The overlapping body's must be part of this area's in order to be detected.
For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
Returns a list of intersecting s. The overlapping area's must be part of this area's in order to be detected.
For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
If true, the given physics body overlaps the Area2D.
Note: The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
The body argument can either be a or a instance (while TileMaps are not physics bodies themselves, they register their tiles with collision shapes as a virtual physics body).
If true, the given area overlaps the Area2D.
Note: The result of this test is not immediate after moving objects. For performance, the list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
The is used to construct a by specifying the attributes as arrays.
The most basic example is the creation of a single triangle:
var vertices = PoolVector3Array()
vertices.push_back(Vector3(0, 1, 0))
vertices.push_back(Vector3(1, 0, 0))
vertices.push_back(Vector3(0, 0, 1))
# Initialize the ArrayMesh.
var arr_mesh = ArrayMesh.new()
var arrays = []
arrays.resize(ArrayMesh.ARRAY_MAX)
arrays[ArrayMesh.ARRAY_VERTEX] = vertices
# Create the Mesh.
arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)
var m = MeshInstance.new()
m.mesh = arr_mesh
The is ready to be added to the to be shown.
See also , and for procedural geometry generation.
Note: Godot uses clockwise winding order for front faces of triangle primitive modes.
Value used internally when no indices are present.
Amount of weights/bone indices per vertex (always 4).
Array format will include vertices (mandatory).
Array format will include normals.
Array format will include tangents.
Array format will include a color array.
Array format will include UVs.
Array format will include another set of UVs.
Array format will include bone indices.
Array format will include bone weights.
Index array will be used.
, , or of vertex positions.
of vertex normals.
of vertex tangents. Each element in groups of 4 floats, first 3 floats determine the tangent, and the last the binormal direction as -1 or 1.
of vertex colors.
for UV coordinates.
for second UV coordinates.
or of bone indices. Each element in groups of 4 floats.
of bone weights. Each element in groups of 4 floats.
of integers used as indices referencing vertices, colors, normals, tangents, and textures. All of those arrays must have the same number of elements as the vertex array. No index can be beyond the vertex array size. When this index array is present, it puts the function into "index mode," where the index selects the *i*'th vertex, normal, tangent, color, UV, etc. This means if you want to have different normals or colors along an edge, you have to duplicate the vertices.
For triangles, the index array is interpreted as triples, referring to the vertices of each triangle. For lines, the index array is in pairs indicating the start and end of each line.
Represents the size of the enum.
Sets the blend shape mode to one of .
Overrides the with one defined by user for use with frustum culling. Especially useful to avoid unexpected culling when using a shader to offset vertices.
Adds name for a blend shape that will be added with . Must be called before surface is added.
Returns the number of blend shapes that the holds.
Returns the name of the blend shape at this index.
Removes all blend shapes from this .
Creates a new surface.
Surfaces are created to be rendered using a primitive, which may be any of the types defined in . (As a note, when using indices, it is recommended to only use points, lines, or triangles.) will become the surf_idx for this new surface.
The arrays argument is an array of arrays. See for the values used in this array. For example, arrays[0] is the array of vertices. That first vertex sub-array is always required; the others are optional. Adding an index array puts this function into "index mode" where the vertex and other arrays become the sources of data and the index array defines the vertex order. All sub-arrays must have the same length as the vertex array or be empty, except for if it is used.
compress_flags is a bitfield made of values. It defaults to .
Note: The default compress_flags enable , which makes vertex colors stored as 8-bit unsigned integers. This will clamp overbright vertex colors to Color(1, 1, 1, 1) and reduce their precision. To store HDR vertex colors, remove the vertex color compression flag by passing Mesh.ARRAY_COMPRESS_DEFAULT ^ Mesh.ARRAY_COMPRESS_COLOR as the value of compress_flags.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Removes all surfaces from this .
Removes a surface at position surf_idx, shifting greater surfaces one surf_idx slot down.
Updates a specified region of mesh arrays on the GPU.
Warning: Only use if you know what you are doing. You can easily cause crashes by calling this function with improper arguments.
Returns the length in vertices of the vertex array in the requested surface (see ).
Returns the length in indices of the index array in the requested surface (see ).
Returns the format mask of the requested surface (see ).
Returns the primitive type of the requested surface (see ).
Returns the index of the first surface with this name held within this . If none are found, -1 is returned.
Sets a name for a given surface.
Gets the name assigned to this surface.
Will regenerate normal maps for the .
Will perform a UV unwrap on the to prepare the mesh for lightmapping.
Arranges child controls in a way to preserve their aspect ratio automatically whenever the container is resized. Solves the problem where the container size is dynamic and the contents' size needs to adjust accordingly without losing proportions.
Aligns child controls with the beginning (left or top) of the container.
Aligns child controls with the center of the container.
Aligns child controls with the end (right or bottom) of the container.
The height of child controls is automatically adjusted based on the width of the container.
The width of child controls is automatically adjusted based on the height of the container.
The bounding rectangle of child controls is automatically adjusted to fit inside the container while keeping the aspect ratio.
The width and height of child controls is automatically adjusted to make their bounding rectangle cover the entire area of the container while keeping the aspect ratio.
When the bounding rectangle of child controls exceed the container's size and is enabled, this allows to show only the container's area restricted by its own bounding rectangle.
The aspect ratio to enforce on child controls. This is the width divided by the height. The ratio depends on the .
The stretch mode used to align child controls.
Specifies the horizontal relative position of child controls.
Specifies the vertical relative position of child controls.
resource that crops out one part of the texture, defined by . The main use case is cropping out textures from a texture atlas, which is a big texture file that packs multiple smaller textures. Consists of a for the , a that defines the area of to use, and a that defines the border width.
cannot be used in an , cannot be tiled in nodes such as , and does not work properly if used inside of other resources. Multiple resources can be used to crop multiple textures from the atlas. Using a texture atlas helps to optimize video memory costs and render calls compared to using multiple small files.
Note: AtlasTextures don't support repetition. The and flags are ignored when using an AtlasTexture.
The texture that contains the atlas. Can be any subtype.
The AtlasTexture's used region.
The margin around the region. The 's Rect2.size parameter ("w" and "h" in the editor) resizes the texture so it fits within the margin.
If true, clips the area outside of the region to avoid bleeding of the surrounding texture pixels.
Stores position, muting, solo, bypass, effects, effect position, volume, and the connections between buses. See for usage.
Base resource for audio bus. Applies an audio effect on the bus that the resource is applied on.
Increases or decreases the volume being routed through the audio bus.
Amount of amplification in decibels. Positive values make the sound louder, negative values make it quieter. Value can range from -80 to 24.
Limits the frequencies in a range around the and allows frequencies outside of this range to pass.
Attenuates the frequencies inside of a range around the and cuts frequencies outside of this band.
AudioEffectCapture is an AudioEffect which copies all audio frames from the attached audio effect bus into its internal ring buffer.
Application code should consume these audio frames from this ring buffer using and process it as needed, for example to capture data from an , implement application-defined effects, or to transmit audio over the network. When capturing audio data from a microphone, the format of the samples will be stereo 32-bit floating point PCM.
Note: must be true for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.
Length of the internal ring buffer, in seconds. Setting the buffer length will have no effect if already initialized.
Returns true if at least frames audio frames are available to read in the internal ring buffer.
Gets the next frames audio samples from the internal ring buffer.
Returns a containing exactly frames audio samples if available, or an empty if insufficient data was available.
Clears the internal ring buffer.
Returns the number of frames available to read using .
Returns the number of audio frames discarded from the audio bus due to full buffer.
Returns the total size of the internal ring buffer in frames.
Returns the number of audio frames inserted from the audio bus.
Adds a chorus audio effect. The effect applies a filter with voices to duplicate the audio source and manipulate it through the filter.
The amount of voices in the effect.
The effect's raw signal.
The effect's processed signal.
The voice's signal delay.
The voice's filter rate.
The voice filter's depth.
The voice's volume.
The voice's cutoff frequency.
The voice's pan level.
The voice's signal delay.
The voice's filter rate.
The voice filter's depth.
The voice's volume.
The voice's cutoff frequency.
The voice's pan level.
The voice's signal delay.
The voice's filter rate.
The voice filter's depth.
The voice's volume.
The voice's cutoff frequency.
The voice's pan level.
The voice's signal delay.
The voice's filter rate.
The voice filter's depth.
The voice's volume.
The voice's cutoff frequency.
The voice's pan level.
Dynamic range compressor reduces the level of the sound when the amplitude goes over a certain threshold in Decibels. One of the main uses of a compressor is to increase the dynamic range by clipping as little as possible (when sound goes over 0dB).
Compressor has many uses in the mix:
- In the Master bus to compress the whole output (although an is probably better).
- In voice channels to ensure they sound as balanced as possible.
- Sidechained. This can reduce the sound level sidechained with another audio bus for threshold detection. This technique is common in video game mixing to the level of music and SFX while voices are being heard.
- Accentuates transients by using a wider attack, making effects sound more punchy.
The level above which compression is applied to the audio. Value can range from -60 to 0.
Amount of compression applied to the audio once it passes the threshold level. The higher the ratio, the more the loud parts of the audio will be compressed. Value can range from 1 to 48.
Gain applied to the output signal.
Compressor's reaction time when the signal exceeds the threshold, in microseconds. Value can range from 20 to 2000.
Compressor's delay time to stop reducing the signal after the signal level falls below the threshold, in milliseconds. Value can range from 20 to 2000.
Balance between original signal and effect signal. Value can range from 0 (totally dry) to 1 (totally wet).
Reduce the sound level using another audio bus for threshold detection.
Plays input signal back after a period of time. The delayed signal may be played back multiple times to create the sound of a repeating, decaying echo. Delay effects range from a subtle echo effect to a pronounced blending of previous sounds with new sounds.
Output percent of original sound. At 0, only delayed sounds are output. Value can range from 0 to 1.
If true, tap1 will be enabled.
tap1 delay time in milliseconds.
Sound level for tap1.
Pan position for tap1. Value can range from -1 (fully left) to 1 (fully right).
If true, tap2 will be enabled.
Tap2 delay time in milliseconds.
Sound level for tap2.
Pan position for tap2. Value can range from -1 (fully left) to 1 (fully right).
If true, feedback is enabled.
Feedback delay time in milliseconds.
Sound level for tap1.
Low-pass filter for feedback, in Hz. Frequencies below this value are filtered out of the source signal.
Different types are available: clip, tan, lo-fi (bit crushing), overdrive, or waveshape.
By distorting the waveform the frequency content change, which will often make the sound "crunchy" or "abrasive". For games, it can simulate sound coming from some saturated device or speaker very efficiently.
Digital distortion effect which cuts off peaks at the top and bottom of the waveform.
Low-resolution digital distortion effect. You can use it to emulate the sound of early digital audio devices.
Emulates the warm distortion produced by a field effect transistor, which is commonly used in solid-state musical instrument amplifiers.
Waveshaper distortions are used mainly by electronic musicians to achieve an extra-abrasive sound.
Distortion type.
Increases or decreases the volume before the effect. Value can range from -60 to 60.
High-pass filter, in Hz. Frequencies higher than this value will not be affected by the distortion. Value can range from 1 to 20000.
Distortion power. Value can range from 0 to 1.
Increases or decreases the volume after the effect. Value can range from -80 to 24.
AudioEffectEQ gives you control over frequencies. Use it to compensate for existing deficiencies in audio. AudioEffectEQs are useful on the Master bus to completely master a mix and give it more character. They are also useful when a game is run on a mobile device, to adjust the mix to that kind of speakers (it can be added but disabled when headphones are plugged).
Sets band's gain at the specified index, in dB.
Returns the band's gain at the specified index, in dB.
Returns the number of bands of the equalizer.
Frequency bands:
Band 1: 31 Hz
Band 2: 62 Hz
Band 3: 125 Hz
Band 4: 250 Hz
Band 5: 500 Hz
Band 6: 1000 Hz
Band 7: 2000 Hz
Band 8: 4000 Hz
Band 9: 8000 Hz
Band 10: 16000 Hz
See also , , .
Frequency bands:
Band 1: 22 Hz
Band 2: 32 Hz
Band 3: 44 Hz
Band 4: 63 Hz
Band 5: 90 Hz
Band 6: 125 Hz
Band 7: 175 Hz
Band 8: 250 Hz
Band 9: 350 Hz
Band 10: 500 Hz
Band 11: 700 Hz
Band 12: 1000 Hz
Band 13: 1400 Hz
Band 14: 2000 Hz
Band 15: 2800 Hz
Band 16: 4000 Hz
Band 17: 5600 Hz
Band 18: 8000 Hz
Band 19: 11000 Hz
Band 20: 16000 Hz
Band 21: 22000 Hz
See also , , .
Frequency bands:
Band 1: 32 Hz
Band 2: 100 Hz
Band 3: 320 Hz
Band 4: 1000 Hz
Band 5: 3200 Hz
Band 6: 10000 Hz
See also , , .
Allows frequencies other than the to pass.
Threshold frequency for the filter, in Hz.
Amount of boost in the frequency range near the cutoff frequency.
Gain amount of the frequencies after the filter.
Cuts frequencies lower than the and allows higher frequencies to pass.
A limiter is similar to a compressor, but it's less flexible and designed to disallow sound going over a given dB threshold. Adding one in the Master bus is always recommended to reduce the effects of clipping.
Soft clipping starts to reduce the peaks a little below the threshold level and progressively increases its effect as the input level increases such that the threshold is never exceeded.
The waveform's maximum allowed value, in decibels. Value can range from -20 to -0.1.
Threshold from which the limiter begins to be active, in decibels. Value can range from -30 to 0.
Applies a gain to the limited waves, in decibels. Value can range from 0 to 6.
Cuts frequencies higher than the and allows lower frequencies to pass.
Attenuates frequencies in a narrow band around the and cuts frequencies outside of this range.
Determines how much of an audio signal is sent to the left and right buses.
Pan position. Value can range from -1 (fully left) to 1 (fully right).
Combines phase-shifted signals with the original signal. The movement of the phase-shifted signals is controlled using a low-frequency oscillator.
Determines the minimum frequency affected by the LFO modulations, in Hz. Value can range from 10 to 10000.
Determines the maximum frequency affected by the LFO modulations, in Hz. Value can range from 10 to 10000.
Adjusts the rate in Hz at which the effect sweeps up and down across the frequency range.
Output percent of modified sound. Value can range from 0.1 to 0.9.
Governs how high the filter frequencies sweep. Low value will primarily affect bass frequencies. High value can sweep high into the treble. Value can range from 0.1 to 4.
Allows modulation of pitch independently of tempo. All frequencies can be increased/decreased with minimal effect on transients.
Use a buffer of 256 samples for the Fast Fourier transform. Lowest latency, but least stable over time.
Use a buffer of 512 samples for the Fast Fourier transform. Low latency, but less stable over time.
Use a buffer of 1024 samples for the Fast Fourier transform. This is a compromise between latency and stability over time.
Use a buffer of 2048 samples for the Fast Fourier transform. High latency, but stable over time.
Use a buffer of 4096 samples for the Fast Fourier transform. Highest latency, but most stable over time.
Represents the size of the enum.
The pitch scale to use. 1.0 is the default pitch and plays sounds unaltered. can range from 0.0 (infinitely low pitch, inaudible) to 16 (16 times higher than the initial pitch).
The oversampling factor to use. Higher values result in better quality, but are more demanding on the CPU and may cause audio cracking if the CPU can't keep up.
The size of the Fast Fourier transform buffer. Higher values smooth out the effect over time, but have greater latency. The effects of this higher latency are especially noticeable on sounds that have sudden amplitude changes.
Allows the user to record the sound from an audio bus. This can include all audio output by Godot when used on the "Master" audio bus.
Can be used (with an ) to record from a microphone.
It sets and gets the format in which the audio file will be recorded (8-bit, 16-bit, or compressed). It checks whether or not the recording is active, and if it is, records the sound. It then returns the recorded sample.
Specifies the format in which the sample will be recorded. See for available formats.
If true, the sound will be recorded. Note that restarting the recording will remove the previously recorded sample.
Returns whether the recording is active or not.
Returns the recorded sample.
Simulates rooms of different sizes. Its parameters can be adjusted to simulate the sound of a specific room.
Time between the original signal and the early reflections of the reverb signal, in milliseconds.
Output percent of predelay. Value can range from 0 to 1.
Dimensions of simulated room. Bigger means more echoes. Value can range from 0 to 1.
Defines how reflective the imaginary room's walls are. Value can range from 0 to 1.
Widens or narrows the stereo image of the reverb tail. 1 means fully widens. Value can range from 0 to 1.
High-pass filter passes signals with a frequency higher than a certain cutoff frequency and attenuates signals with frequencies lower than the cutoff frequency. Value can range from 0 to 1.
Output percent of original sound. At 0, only modified sound is outputted. Value can range from 0 to 1.
Output percent of modified sound. At 0, only original sound is outputted. Value can range from 0 to 1.
This audio effect does not affect sound output, but can be used for real-time audio visualizations.
See also for procedurally generating sounds.
Use a buffer of 256 samples for the Fast Fourier transform. Lowest latency, but least stable over time.
Use a buffer of 512 samples for the Fast Fourier transform. Low latency, but less stable over time.
Use a buffer of 1024 samples for the Fast Fourier transform. This is a compromise between latency and stability over time.
Use a buffer of 2048 samples for the Fast Fourier transform. High latency, but stable over time.
Use a buffer of 4096 samples for the Fast Fourier transform. Highest latency, but most stable over time.
Represents the size of the enum.
The length of the buffer to keep (in seconds). Higher values keep data around for longer, but require more memory.
The size of the Fast Fourier transform buffer. Higher values smooth out the spectrum analysis over time, but have greater latency. The effects of this higher latency are especially noticeable with sudden amplitude changes.
Use the average value as magnitude.
Use the maximum value as magnitude.
is a low-level server interface for audio access. It is in charge of creating sample data (playable audio) as well as its playback via a voice interface.
Two or fewer speakers were detected.
A 3.1 channel surround setup was detected.
A 5.1 channel surround setup was detected.
A 7.1 channel surround setup was detected.
Number of available audio buses.
Name of the current device for audio output (see ). On systems with multiple audio outputs (such as analog, USB and HDMI audio), this can be used to select the audio output device. The value "Default" will play audio on the system-wide default audio output. If an invalid device name is set, the value will be reverted back to "Default".
Name of the current device for audio input (see ). On systems with multiple audio inputs (such as analog, USB and HDMI audio), this can be used to select the audio input device. The value "Default" will record audio on the system-wide default audio input. If an invalid device name is set, the value will be reverted back to "Default".
Note: must be true for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.
Scales the rate at which audio is played (i.e. setting it to 0.5 will make the audio be played twice as fast).
Removes the bus at index index.
Adds a bus at at_position.
Moves the bus from index index to index to_index.
Sets the name of the bus at index bus_idx to name.
Returns the name of the bus with the index bus_idx.
Returns the index of the bus with the name bus_name.
Returns the amount of channels of the bus at index bus_idx.
Sets the volume of the bus at index bus_idx to volume_db.
Returns the volume of the bus at index bus_idx in dB.
Connects the output of the bus at bus_idx to the bus named send.
Returns the name of the bus that the bus at index bus_idx sends to.
If true, the bus at index bus_idx is in solo mode.
If true, the bus at index bus_idx is in solo mode.
If true, the bus at index bus_idx is muted.
If true, the bus at index bus_idx is muted.
If true, the bus at index bus_idx is bypassing effects.
If true, the bus at index bus_idx is bypassing effects.
Adds an effect to the bus bus_idx at at_position.
Removes the effect at index effect_idx from the bus at index bus_idx.
Returns the number of effects on the bus at bus_idx.
Returns the at position effect_idx in bus bus_idx.
Returns the assigned to the given bus and effect indices (and optionally channel).
Swaps the position of two effects in bus bus_idx.
If true, the effect at index effect_idx on the bus at index bus_idx is enabled.
If true, the effect at index effect_idx on the bus at index bus_idx is enabled.
Returns the peak volume of the left speaker at bus index bus_idx and channel index channel.
Returns the peak volume of the right speaker at bus index bus_idx and channel index channel.
Locks the audio driver's main loop.
Note: Remember to unlock it afterwards.
Unlocks the audio driver's main loop. (After locking it, you should always unlock it.)
Returns the speaker configuration.
Returns the sample rate at the output of the .
Returns the names of all audio devices detected on the system.
Returns the relative time until the next mix occurs.
Returns the relative time since the last mix occurred.
Returns the audio driver's output latency.
Returns the names of all audio input devices detected on the system.
Note: must be true for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.
Overwrites the currently used .
Generates an using the available buses and effects.
Base class for audio streams. Audio streams are used for sound effects and music playback, and support WAV (via ) and OGG (via ) file formats.
Returns the length of the audio stream in seconds.
This audio stream does not play back sounds, but expects a script to generate audio data for it instead. See also .
See also for performing real-time audio spectrum analysis.
Note: Due to performance constraints, this class is best used from C# or from a compiled language via GDNative. If you still want to use this class from GDScript, consider using a lower such as 11,025 Hz or 22,050 Hz.
The sample rate to use (in Hz). Higher values are more demanding for the CPU to generate, but result in better quality.
In games, common sample rates in use are 11025, 16000, 22050, 32000, 44100, and 48000.
According to the Nyquist-Shannon sampling theorem, there is no quality difference to human hearing when going past 40,000 Hz (since most humans can only hear up to ~20,000 Hz, often less). If you are generating lower-pitched sounds such as voices, lower sample rates such as 32000 or 22050 may be usable with no loss in quality.
The length of the buffer to generate (in seconds). Lower values result in less latency, but require the script to generate audio data faster, resulting in increased CPU usage and more risk for audio cracking if the CPU can't keep up.
This class is meant to be used with to play back the generated audio in real-time.
Pushes a single audio data frame to the buffer. This is usually less efficient than in C# and compiled languages via GDNative, but may be more efficient in GDScript.
Returns true if a buffer of the size amount can be pushed to the audio sample data buffer without overflowing it, false otherwise.
Pushes several audio data frames to the buffer. This is usually more efficient than in C# and compiled languages via GDNative, but may be less efficient in GDScript.
Returns the number of audio data frames left to play. If this returned number reaches 0, the audio will stop playing until frames are added again. Therefore, make sure your script can always generate and push new audio frames fast enough to avoid audio cracking.
Clears the audio sample data buffer.
MP3 audio stream driver.
Contains the audio data in bytes.
If true, the stream will automatically loop when it reaches the end.
Time in seconds at which the stream starts after being looped.
When used directly in an node, plays back microphone input in real-time. This can be used in conjunction with to process the data or save it.
Note: must be true for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.
OGG Vorbis audio stream driver.
Contains the audio data in bytes.
If true, the stream will automatically loop when it reaches the end.
Time in seconds at which the stream starts after being looped.
Can play, loop, pause a scroll through audio. See and for usage.
Plays an audio stream non-positionally.
To play audio positionally, use or instead of .
The audio will be played only on the first channel.
The audio will be played on all surround channels.
The audio will be played on the second channel, which is usually the center.
The object to be played.
Volume of sound, in dB.
The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
If true, audio is playing.
If true, audio plays when added to scene tree.
If true, the playback is paused. You can resume it by setting stream_paused to false.
If the audio configuration has more than two speakers, this sets the target channels. See constants.
Bus on which this audio is playing.
Note: When setting this property, keep in mind that no validation is performed to see if the given name matches an existing bus. This is because audio bus layouts might be loaded after this property is set. If this given name can't be resolved at runtime, it will fall back to "Master".
Plays the audio from the given from_position, in seconds.
Sets the position from which audio will be played, in seconds.
Stops the audio.
Returns the position in the in seconds.
Returns the object associated with this .
Plays audio that dampens with distance from a given position.
By default, audio is heard from the screen center. This can be changed by adding a node to the scene and enabling it by calling on it.
See also to play a sound non-positionally.
Note: Hiding an node does not disable its audio output. To temporarily disable an 's audio output, set to a very low value like -100 (which isn't audible to human hearing).
The object to be played.
Base volume without dampening.
The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
If true, audio is playing.
If true, audio plays when added to scene tree.
If true, the playback is paused. You can resume it by setting stream_paused to false.
Maximum distance from which audio is still hearable.
Dampens audio over distance with this as an exponent.
Bus on which this audio is playing.
Note: When setting this property, keep in mind that no validation is performed to see if the given name matches an existing bus. This is because audio bus layouts might be loaded after this property is set. If this given name can't be resolved at runtime, it will fall back to "Master".
Determines which layers affect the sound for reverb and audio bus effects. Areas can be used to redirect s so that they play in a certain audio bus. An example of how you might use this is making a "water" area so that sounds played in the water are redirected through an audio bus to make them sound like they are being played underwater.
Plays the audio from the given position from_position, in seconds.
Sets the position from which audio will be played, in seconds.
Stops the audio.
Returns the position in the .
Returns the object associated with this .
Plays a sound effect with directed sound effects, dampens with distance if needed, generates effect of hearable position in space. For greater realism, a low-pass filter is automatically applied to distant sounds. This can be disabled by setting to 20500.
By default, audio is heard from the camera position. This can be changed by adding a node to the scene and enabling it by calling on it.
See also to play a sound non-positionally.
Note: Hiding an node does not disable its audio output. To temporarily disable an 's audio output, set to a very low value like -100 (which isn't audible to human hearing).
Linear dampening of loudness according to distance.
Squared dampening of loudness according to distance.
Logarithmic dampening of loudness according to distance.
No dampening of loudness according to distance. The sound will still be heard positionally, unlike an . can be combined with a value greater than 0.0 to achieve linear attenuation clamped to a sphere of a defined size.
Mix this audio in, even when it's out of range. This increases CPU usage, but keeps the sound playing at the correct position if the camera leaves and enters the 's radius.
Pause this audio when it gets out of range. This decreases CPU usage, but will cause the sound to restart if the camera leaves and enters the 's radius.
Disables doppler tracking.
Executes doppler tracking in idle step (every rendered frame).
Executes doppler tracking in physics step (every simulated physics frame).
The resource to be played.
Decides if audio should get quieter with distance linearly, quadratically, logarithmically, or not be affected by distance, effectively disabling attenuation.
The base sound level unaffected by dampening, in decibels.
The factor for the attenuation effect. Higher values make the sound audible over a larger distance.
Sets the absolute maximum of the soundlevel, in decibels.
The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
If true, audio is playing.
If true, audio plays when the AudioStreamPlayer3D node is added to scene tree.
If true, the playback is paused. You can resume it by setting to false.
Sets the distance from which the takes effect. Has no effect if set to 0.
Decides if audio should pause when source is outside of range.
The bus on which this audio is playing.
Note: When setting this property, keep in mind that no validation is performed to see if the given name matches an existing bus. This is because audio bus layouts might be loaded after this property is set. If this given name can't be resolved at runtime, it will fall back to "Master".
Determines which layers affect the sound for reverb and audio bus effects. Areas can be used to redirect s so that they play in a certain audio bus. An example of how you might use this is making a "water" area so that sounds played in the water are redirected through an audio bus to make them sound like they are being played underwater.
If true, the audio should be dampened according to the direction of the sound.
The angle in which the audio reaches cameras undampened.
Dampens audio if camera is outside of and is set by this factor, in decibels.
Dampens audio using a low-pass filter above this frequency, in Hz. To disable the dampening effect entirely, set this to 20500 as this frequency is above the human hearing limit.
Amount how much the filter affects the loudness, in decibels.
Decides in which step the Doppler effect should be calculated.
Note: Only effective if the current 's property is set to a value other than .
Plays the audio from the given position from_position, in seconds.
Sets the position from which audio will be played, in seconds.
Stops the audio.
Returns the position in the .
Returns the object associated with this .
Randomly varies pitch on each start.
The current .
The intensity of random pitch variation.
AudioStreamSample stores sound samples loaded from WAV files. To play the stored sound, use an (for non-positional audio) or / (for positional audio). The sound can be looped.
This class can also be used to store dynamically-generated PCM audio data. See also for procedural audio generation.
Audio does not loop.
Audio loops the data between and , playing forward only.
Audio loops the data between and , playing back and forth.
Audio loops the data between and , playing backward only.
8-bit audio codec.
16-bit audio codec.
Audio is compressed using IMA ADPCM.
Contains the audio data in bytes.
Note: This property expects signed PCM8 data. To convert unsigned PCM8 to signed PCM8, subtract 128 from each byte.
Audio format. See constants for values.
The loop mode. This information will be imported automatically from the WAV file if present. See constants for values.
The loop start point (in number of samples, relative to the beginning of the sample). This information will be imported automatically from the WAV file if present.
The loop end point (in number of samples, relative to the beginning of the sample). This information will be imported automatically from the WAV file if present.
The sample rate for mixing this audio. Higher values require more storage space, but result in better quality.
In games, common sample rates in use are 11025, 16000, 22050, 32000, 44100, and 48000.
According to the Nyquist-Shannon sampling theorem, there is no quality difference to human hearing when going past 40,000 Hz (since most humans can only hear up to ~20,000 Hz, often less). If you are using lower-pitched sounds such as voices, lower sample rates such as 32000 or 22050 may be usable with no loss in quality.
If true, audio is stereo.
Saves the AudioStreamSample as a WAV file to path. Samples with IMA ADPCM format can't be saved.
Note: A .wav extension is automatically appended to path if it is missing.
Node for back-buffering the currently-displayed screen. The region defined in the BackBufferCopy node is buffered with the content of the screen it covers, or the entire screen according to the copy mode set. Use the texture(SCREEN_TEXTURE, ...) function in your shader scripts to access the buffer.
Note: Since this node inherits from (and not ), anchors and margins won't apply to child -derived nodes. This can be problematic when resizing the window. To avoid this, add -derived nodes as siblings to the BackBufferCopy node instead of adding them as children.
Disables the buffering mode. This means the BackBufferCopy node will directly use the portion of screen it covers.
BackBufferCopy buffers a rectangular region.
BackBufferCopy buffers the entire screen.
Buffer mode. See constants.
The area covered by the BackBufferCopy. Only used if is .
Baked lightmaps are an alternative workflow for adding indirect (or baked) lighting to a scene. Unlike the approach, baked lightmaps work fine on low-end PCs and mobile devices as they consume almost no resources in run-time.
Procedural generation: Lightmap baking functionality is only available in the editor. This means is not suited to procedurally generated or user-built levels. For procedurally generated or user-built levels, use instead.
Note: Due to how lightmaps work, most properties only have a visible effect once lightmaps are baked again.
The lowest bake quality mode. Fastest to calculate.
The default bake quality mode.
A higher bake quality mode. Takes longer to calculate.
The highest bake quality mode. Takes the longest to calculate.
Baking was successful.
Returns if no viable save path is found. This can happen where an is not specified or when the save location is invalid.
Currently unused.
Returns when the baker cannot save per-mesh textures to file.
The size of the generated lightmaps is too large.
Some mesh contains UV2 values outside the [0,1] range.
Returns if user cancels baking.
Returns if lightmapper can't be created. Unless you are using a custom lightmapper, please report this as bug.
There is no root node to start baking from. Either provide from_node argument or attach this node to a parent that should be used as root.
No environment is used during baking.
The baked environment is automatically picked from the current scene.
A custom sky is used as environment during baking.
A custom solid color is used as environment during baking.
Size of the baked lightmap. Only meshes inside this region will be included in the baked lightmap, also used as the bounds of the captured region for dynamic lighting.
Determines the amount of samples per texel used in indirect light baking. The amount of samples for each quality level can be configured in the project settings.
Number of light bounces that are taken into account during baking. See also .
The energy multiplier for each bounce. Higher values will make indirect lighting brighter. A value of 1.0 represents physically accurate behavior, but higher values can be used to make indirect lighting propagate more visibly when using a low number of bounces. This can be used to speed up bake times by lowering the number of then increasing . Unlike , this property does not affect direct lighting emitted by light nodes, emissive materials and the environment.
Note: only has an effect if is set to a value greater than or equal to 1.
When enabled, a lightmap denoiser will be used to reduce the noise inherent to Monte Carlo based global illumination.
If true, stores the lightmap textures in a high dynamic range format (EXR). If false, stores the lightmap texture in a low dynamic range PNG image. This can be set to false to reduce disk usage, but light values over 1.0 will be clamped and you may see banding caused by the reduced precision.
Note: Setting to true will decrease lightmap banding even when using the GLES2 backend or if is false.
Store full color values in the lightmap textures. When disabled, lightmap textures will store a single brightness channel. Can be disabled to reduce disk usage if the scene contains only white lights or you don't mind losing color information in indirect lighting.
Raycasting bias used during baking to avoid floating point precision issues.
If a baked mesh doesn't have a UV2 size hint, this value will be used to roughly compute a suitable lightmap size.
If true, the lightmapper will merge the textures for all meshes into one or several large layered textures. If false, every mesh will get its own lightmap texture, which is less efficient.
Note: Atlas lightmap rendering is only supported in GLES3, not GLES2. Non-atlas lightmap rendering is supported by both GLES3 and GLES2. If is true, consider baking lightmaps with set to false so that the resulting lightmap is visible in both GLES3 and GLES2.
Maximum size of each lightmap layer, only used when is enabled.
Decides which environment to use during baking.
The resource to use when is set o .
The rotation of the baked custom sky.
The environment color when is set to .
The energy scaling factor when when is set to or .
Minimum ambient light for all the lightmap texels. This doesn't take into account any occlusion from the scene's geometry, it simply ensures a minimum amount of light on all the lightmap texels. Can be used for artistic control on shadow color.
When enabled, an octree containing the scene's lighting information will be computed. This octree will then be used to light dynamic objects in the scene.
Grid size used for real-time capture information on dynamic objects.
Bake quality of the capture data.
Bias value to reduce the amount of light propagation in the captured octree.
Deprecated, in previous versions it determined the location where lightmaps were be saved.
The calculated light data.
Bakes the lightmap, scanning from the given from_node root and saves the resulting in data_save_path. If no root node is provided, parent of this node will be used as root instead. If no save path is provided it will try to match the path from the current .
Global energy multiplier for baked and dynamic capture objects. This can be changed at run-time without having to bake lightmaps again.
To adjust only the energy of indirect lighting (without affecting direct lighting or emissive materials), adjust and bake lightmaps again.
Controls whether dynamic capture objects receive environment lighting or not.
BaseButton is the abstract base class for buttons, so it shouldn't be used directly (it doesn't display anything). Other types of buttons inherit from it.
Require just a press to consider the button clicked.
Require a press and a subsequent release before considering the button clicked.
The normal state (i.e. not pressed, not hovered, not toggled and enabled) of buttons.
The state of buttons are pressed.
The state of buttons are hovered.
The state of buttons are disabled.
The state of buttons are both hovered and pressed.
If true, the button is in disabled state and can't be clicked or toggled.
If true, the button is in toggle mode. Makes the button flip state between pressed and unpressed each time its area is clicked.
If true, the button will add information about its shortcut in the tooltip.
If true, the button's state is pressed. Means the button is pressed down or toggled (if is active). Only works if is true.
Note: Setting will result in toggled to be emitted. If you want to change the pressed state without emitting that signal, use .
Determines when the button is considered clicked, one of the constants.
Binary mask to choose which mouse buttons this button will respond to.
To allow both left-click and right-click, use BUTTON_MASK_LEFT | BUTTON_MASK_RIGHT.
Deprecated. This property has been deprecated due to redundancy and will be removed in Godot 4.0. This property no longer has any effect when set. Please use instead.
If true, the button stays pressed when moving the cursor outside the button while pressing it.
Note: This property only affects the button's visual appearance. Signals will be emitted at the same moment regardless of this property's value.
associated to the button.
associated to the button.
Called when the button is pressed. If you need to know the button's pressed state (and is active), use instead.
Called when the button is toggled (only if is active).
Changes the state of the button, without emitting toggled. Use when you just want to change the state of the button without sending the pressed event (e.g. when initializing scene). Only works if is true.
Note: This method doesn't unpress other buttons in its button .
Returns true if the mouse has entered the button and has not left it yet.
Returns the visual state used to draw the button. This is useful mainly when implementing your own draw code by either overriding _draw() or connecting to "draw" signal. The visual state of the button is defined by the enum.
A two-dimensional array of boolean values, can be used to efficiently store a binary matrix (every matrix element takes only one bit) and query the values using natural cartesian coordinates.
Creates a bitmap with the specified size, filled with false.
Creates a bitmap that matches the given image dimensions, every element of the bitmap is set to false if the alpha value of the image at that position is equal to threshold or less, and true in other case.
Sets the bitmap's element at the specified position, to the specified value.
Returns bitmap's value at the specified position.
Sets a rectangular portion of the bitmap to the specified value.
Returns the amount of bitmap elements that are set to true.
Returns bitmap's dimensions.
Resizes the image to new_size.
Applies morphological dilation or erosion to the bitmap. If pixels is positive, dilation is applied to the bitmap. If pixels is negative, erosion is applied to the bitmap. rect defines the area where the morphological operation is applied. Pixels located outside the rect are unaffected by .
Returns an image of the same size as the bitmap and with a of type FORMAT_L8. true bits of the bitmap are being converted into white pixels, and false bits into black.
Renders text using *.fnt fonts containing texture atlases. Supports distance fields. For using vector font files like TTF directly, see .
Total font height (ascent plus descent) in pixels.
Ascent (number of pixels above the baseline).
If true, distance field hint is enabled.
The fallback font.
Creates a BitmapFont from the *.fnt file at path.
Adds a kerning pair to the as a difference. Kerning pairs are special cases where a typeface advance is determined by the next character.
Returns a kerning pair as a difference.
Adds a texture to the .
Adds a character to the font, where character is the Unicode value, texture is the texture index, rect is the region in the texture (in pixels!), align is the (optional) alignment for the character and advance is the (optional) advance.
If the parameter is null, then the default value is new Vector2(0, 0)
Returns the number of textures in the BitmapFont atlas.
Returns the font atlas texture at index idx.
Clears all the font data and settings.
Use a hierarchy of Bone2D bound to a to control, and animate other nodes.
You can use Bone2D and Skeleton2D nodes to animate 2D meshes created with the Polygon 2D UV editor.
Each bone has a transform that you can reset to with . These rest poses are relative to the bone's parent.
If in the editor, you can set the rest pose of an entire skeleton using a menu option, from the code, you need to iterate over the bones to set their individual rest poses.
Rest transform of the bone. You can reset the node's transforms to this value using .
Length of the bone's representation drawn in the editor's viewport in pixels.
Stores the node's current transforms in .
Returns the node's Transform2D if it doesn't have a parent, or its rest pose relative to its parent.
Returns the node's index as part of the entire skeleton. See .
This node must be the child of a node. You can then select a bone for this node to attach to. The BoneAttachment node will copy the transform of the selected bone.
The name of the attached bone.
Arranges child controls vertically or horizontally, and rearranges the controls automatically when their minimum size changes.
Aligns children with the beginning of the container.
Aligns children with the center of the container.
Aligns children with the end of the container.
The alignment of the container's children (must be one of , or ).
Adds a control to the box as a spacer. If true, begin will insert the spacer control in front of other children.
3D box shape that can be a child of a or .
The box's half extents. The width, height and depth of this shape is twice the half extents.
Button is the standard themed button. It can contain text and an icon, and will display them according to the current .
Example of creating a button and assigning an action when pressed by code:
func _ready():
var button = Button.new()
button.text = "Click me"
button.connect("pressed", self, "_button_pressed")
add_child(button)
func _button_pressed():
print("Hello world!")
Buttons (like all Control nodes) can also be created in the editor, but some situations may require creating them from code.
See also which contains common properties and methods associated with this node.
Note: Buttons do not interpret touch input and therefore don't support multitouch, since mouse emulation can only press one button at a given time. Use for buttons that trigger gameplay movement or actions, as supports multitouch.
Align the text to the left.
Align the text to the center.
Align the text to the right.
The button's text that will be displayed inside the button's area.
Button's icon, if text is present the icon will be placed before the text.
To edit margin and spacing of the icon, use hseparation theme property of and content_margin_* properties of the used es.
Flat buttons don't display decoration.
When this property is enabled, text that is too large to fit the button is clipped, when disabled the Button will always be wide enough to hold the text.
Text alignment policy for the button's text, use one of the constants.
Specifies if the icon should be aligned to the left, right, or center of a button. Uses the same constants as the text alignment. If centered, text will draw on top of the icon.
When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect.
Group of . All direct and indirect children buttons become radios. Only one allows being pressed.
should be true.
Returns the current pressed button.
Returns an of s who have this as their (see ).
CPU-based 3D particle node used to create a variety of particle systems and effects.
See also , which provides the same functionality with hardware acceleration, but may not run on older devices.
Note: Unlike , the visibility rect is generated on-the-fly and doesn't need to be configured by the user.
Use with to set .
Use with to set .
Use with to set .
Represents the size of the enum.
All particles will be emitted from a single point.
Particles will be emitted in the volume of a sphere.
Particles will be emitted in the volume of a box.
Particles will be emitted at a position chosen randomly among . Particle color will be modulated by .
Particles will be emitted at a position chosen randomly among . Particle velocity and rotation will be set based on . Particle color will be modulated by .
Particles will be emitted in a ring or cylinder.
Represents the size of the enum.
Use with , , and to set initial velocity properties.
Use with , , and to set angular velocity properties.
Use with , , and to set orbital velocity properties.
Use with , , and to set linear acceleration properties.
Use with , , and to set radial acceleration properties.
Use with , , and to set tangential acceleration properties.
Use with , , and to set damping properties.
Use with , , and to set angle properties.
Use with , , and to set scale properties.
Use with , , and to set hue variation properties.
Use with , , and to set animation speed properties.
Use with , , and to set animation offset properties.
Represents the size of the enum.
Particles are drawn in the order emitted.
Particles are drawn in order of remaining lifetime.
Particles are drawn in order of depth.
If true, particles are being emitted.
The number of particles emitted in one emission cycle (corresponding to the ).
Note: Changing will reset the particle emission, therefore removing all particles that were already emitted before changing .
The amount of time each particle will exist (in seconds).
If true, only one emission cycle occurs. If set true during a cycle, emission will stop at the cycle's end.
Particle system starts as if it had already run for this many seconds.
Particle system's running speed scaling ratio. A value of 0 can be used to pause the particles.
How rapidly particles in an emission cycle are emitted. If greater than 0, there will be a gap in emissions before the next cycle begins.
Emission lifetime randomness ratio.
Particle lifetime randomness ratio.
The particle system's frame rate is fixed to a value. For instance, changing the value to 2 will make the particles render at 2 frames per second. Note this does not slow down the particle system itself.
If true, results in fractional delta calculation which has a smoother particles display effect.
If true, particles use the parent node's coordinate space. If false, they use global coordinates.
Particle draw order. Uses values.
The used for each particle. If null, particles will be spheres.
Particles will be emitted inside this region. See for possible values.
The sphere's radius if is set to .
The rectangle's extents if is set to .
Sets the initial positions to spawn particles when using or .
Sets the direction the particles will be emitted in when using .
Sets the s to modulate particles by when using or .
The radius for the ring shaped emitter when using .
The inner radius for the ring shaped emitter when using .
The height for the ring shaped emitter when using .
The axis for the ring shaped emitter when using .
Align Y axis of particle with the direction of its velocity.
If true, particles rotate around Y axis by .
If true, particles will not move on the z axis.
Unit vector specifying the particles' emission direction.
Each particle's initial direction range from +spread to -spread degrees. Applied to X/Z plane and Y/Z planes.
Amount of in Y/Z plane. A value of 1 restricts particles to X/Z plane.
Gravity applied to every particle.
Initial velocity magnitude for each particle. Direction comes from and the node's orientation.
Initial velocity randomness ratio.
Initial angular velocity applied to each particle in degrees per second. Sets the speed of rotation of the particle.
Angular velocity randomness ratio.
Each particle's angular velocity will vary along this .
Orbital velocity applied to each particle. Makes the particles circle around origin in the local XY plane. Specified in number of full rotations around origin per second.
This property is only available when is true.
Orbital velocity randomness ratio.
Each particle's orbital velocity will vary along this .
Linear acceleration applied to each particle in the direction of motion.
Linear acceleration randomness ratio.
Each particle's linear acceleration will vary along this .
Radial acceleration applied to each particle. Makes particle accelerate away from origin.
Radial acceleration randomness ratio.
Each particle's radial acceleration will vary along this .
Tangential acceleration applied to each particle. Tangential acceleration is perpendicular to the particle's velocity giving the particles a swirling motion.
Tangential acceleration randomness ratio.
Each particle's tangential acceleration will vary along this .
The rate at which particles lose velocity.
Damping randomness ratio.
Damping will vary along this .
Initial rotation applied to each particle, in degrees.
Rotation randomness ratio.
Each particle's rotation will be animated along this .
Initial scale applied to each particle.
Scale randomness ratio.
Each particle's scale will vary along this .
Each particle's initial color. To have particle display color in a make sure to set to true.
Each particle's color will vary along this over its lifetime (multiplied with ).
Each particle's initial color will vary along this (multiplied with ).
Initial hue variation applied to each particle.
Hue variation randomness ratio.
Each particle's hue will vary along this .
Particle animation speed.
Animation speed randomness ratio.
Each particle's animation speed will vary along this .
Particle animation offset.
Animation offset randomness ratio.
Each particle's animation offset will vary along this .
Restarts the particle emitter.
Sets the base value of the parameter specified by .
Returns the base value of the parameter specified by .
Sets the randomness factor of the parameter specified by .
Returns the randomness factor of the parameter specified by .
Sets the of the parameter specified by .
Returns the of the parameter specified by .
Enables or disables the given flag (see for options).
Returns the enabled state of the given flag (see for options).
Sets this node's properties to match a given node with an assigned .
CPU-based 2D particle node used to create a variety of particle systems and effects.
See also , which provides the same functionality with hardware acceleration, but may not run on older devices.
Note: Unlike , the visibility rect is generated on-the-fly and doesn't need to be configured by the user.
Use with to set .
Present for consistency with 3D particle nodes, not used in 2D.
Present for consistency with 3D particle nodes, not used in 2D.
Represents the size of the enum.
All particles will be emitted from a single point.
Particles will be emitted on the surface of a sphere flattened to two dimensions.
Particles will be emitted in the area of a rectangle.
Particles will be emitted at a position chosen randomly among . Particle color will be modulated by .
Particles will be emitted at a position chosen randomly among . Particle velocity and rotation will be set based on . Particle color will be modulated by .
Represents the size of the enum.
Use with , , and to set initial velocity properties.
Use with , , and to set angular velocity properties.
Use with , , and to set orbital velocity properties.
Use with , , and to set linear acceleration properties.
Use with , , and to set radial acceleration properties.
Use with , , and to set tangential acceleration properties.
Use with , , and to set damping properties.
Use with , , and to set angle properties.
Use with , , and to set scale properties.
Use with , , and to set hue variation properties.
Use with , , and to set animation speed properties.
Use with , , and to set animation offset properties.
Represents the size of the enum.
Particles are drawn in the order emitted.
Particles are drawn in order of remaining lifetime.
If true, particles are being emitted.
The number of particles emitted in one emission cycle (corresponding to the ).
Note: Changing will reset the particle emission, therefore removing all particles that were already emitted before changing .
The amount of time each particle will exist (in seconds).
If true, only one emission cycle occurs. If set true during a cycle, emission will stop at the cycle's end.
Particle system starts as if it had already run for this many seconds.
Particle system's running speed scaling ratio. A value of 0 can be used to pause the particles.
How rapidly particles in an emission cycle are emitted. If greater than 0, there will be a gap in emissions before the next cycle begins.
Emission lifetime randomness ratio.
Particle lifetime randomness ratio.
The particle system's frame rate is fixed to a value. For instance, changing the value to 2 will make the particles render at 2 frames per second. Note this does not slow down the simulation of the particle system itself.
If true, results in fractional delta calculation which has a smoother particles display effect.
If true, particles use the parent node's coordinate space. If false, they use global coordinates.
Particle draw order. Uses values.
Particle texture. If null, particles will be squares.
Normal map to be used for the property.
Note: Godot expects the normal map to use X+, Y-, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.
Particles will be emitted inside this region. See for possible values.
The sphere's radius if is set to .
The rectangle's extents if is set to .
Sets the initial positions to spawn particles when using or .
Sets the direction the particles will be emitted in when using .
Sets the s to modulate particles by when using or .
Align Y axis of particle with the direction of its velocity.
Unit vector specifying the particles' emission direction.
Each particle's initial direction range from +spread to -spread degrees.
Gravity applied to every particle.
Initial velocity magnitude for each particle. Direction comes from and the node's orientation.
Initial velocity randomness ratio.
Initial angular velocity applied to each particle in degrees per second. Sets the speed of rotation of the particle.
Angular velocity randomness ratio.
Each particle's angular velocity will vary along this .
Orbital velocity applied to each particle. Makes the particles circle around origin. Specified in number of full rotations around origin per second.
Orbital velocity randomness ratio.
Each particle's orbital velocity will vary along this .
Linear acceleration applied to each particle in the direction of motion.
Linear acceleration randomness ratio.
Each particle's linear acceleration will vary along this .
Radial acceleration applied to each particle. Makes particle accelerate away from origin.
Radial acceleration randomness ratio.
Each particle's radial acceleration will vary along this .
Tangential acceleration applied to each particle. Tangential acceleration is perpendicular to the particle's velocity giving the particles a swirling motion.
Tangential acceleration randomness ratio.
Each particle's tangential acceleration will vary along this .
The rate at which particles lose velocity.
Damping randomness ratio.
Damping will vary along this .
Initial rotation applied to each particle, in degrees.
Rotation randomness ratio.
Each particle's rotation will be animated along this .
Initial scale applied to each particle.
Scale randomness ratio.
Each particle's scale will vary along this .
Each particle's initial color. If is defined, it will be multiplied by this color.
Each particle's color will vary along this (multiplied with ).
Each particle's initial color will vary along this (multiplied with ).
Initial hue variation applied to each particle.
Hue variation randomness ratio.
Each particle's hue will vary along this .
Particle animation speed.
Animation speed randomness ratio.
Each particle's animation speed will vary along this .
Particle animation offset.
Animation offset randomness ratio.
Each particle's animation offset will vary along this .
Restarts the particle emitter.
Sets the base value of the parameter specified by .
Returns the base value of the parameter specified by .
Sets the randomness factor of the parameter specified by .
Returns the randomness factor of the parameter specified by .
Sets the of the parameter specified by .
Returns the of the parameter specified by .
Enables or disables the given flag (see for options).
Returns the enabled state of the given flag (see for options).
Sets this node's properties to match a given node with an assigned .
This node allows you to create a box for use with the CSG system.
Note: CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a with a . Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
Width of the box measured from the center of the box.
Height of the box measured from the center of the box.
Depth of the box measured from the center of the box.
The material used to render the box.
For complex arrangements of shapes, it is sometimes needed to add structure to your CSG nodes. The CSGCombiner node allows you to create this structure. The node encapsulates the result of the CSG operations of its children. In this way, it is possible to do operations on one set of shapes that are children of one CSGCombiner node, and a set of separate operations on a second set of shapes that are children of a second CSGCombiner node, and then do an operation that takes the two end results as its input to create the final shape.
Note: CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a with a . Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
This node allows you to create a cylinder (or cone) for use with the CSG system.
Note: CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a with a . Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
The radius of the cylinder.
The height of the cylinder.
The number of sides of the cylinder, the higher this number the more detail there will be in the cylinder.
If true a cone is created, the will only apply to one side.
If true the normals of the cylinder are set to give a smooth effect making the cylinder seem rounded. If false the cylinder will have a flat shaded look.
The material used to render the cylinder.
This CSG node allows you to use any mesh resource as a CSG shape, provided it is closed, does not self-intersect, does not contain internal faces and has no edges that connect to more than two faces. See also for drawing 2D extruded polygons to be used as CSG nodes.
Note: CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a with a . Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
The resource to use as a CSG shape.
Note: When using an , avoid meshes with vertex normals unless a flat shader is required. By default, CSGMesh will ignore the mesh's vertex normals and use a smooth shader calculated using the faces' normals. If a flat shader is required, ensure that all faces' vertex normals are parallel.
The used in drawing the CSG shape.
An array of 2D points is extruded to quickly and easily create a variety of 3D meshes. See also for using 3D meshes as CSG nodes.
Note: CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a with a . Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
When is set to , will determine the distance, in meters, each interval of the path will extrude.
When is set to , will subdivide the polygons along the path.
The shape is not rotated.
Note: Requires the path's Z coordinates to continually decrease to ensure viable shapes.
The shape is rotated along the path, but it is not rotated around the path axis.
Note: Requires the path's Z coordinates to continually decrease to ensure viable shapes.
The shape follows the path and its rotations around the path axis.
The shape is extruded along the negative Z axis.
The shape is extruded by rotating it around the Y axis.
The shape is extruded along the specified in .
The point array that defines the 2D polygon that is extruded. This can be a convex or concave polygon with 3 or more points. The polygon must not have any intersecting edges. Otherwise, triangulation will fail and no mesh will be generated.
Note: If only 1 or 2 points are defined in , no mesh will be generated.
The used to extrude the .
When is , the depth of the extrusion.
When is , the total number of degrees the is rotated when extruding.
When is , the number of extrusions made.
When is , the location of the object used to extrude the .
When is , this will determine if the interval should be by distance () or subdivision fractions ().
When is , the path interval or ratio of path points to extrusions.
When is , extrusions that are less than this angle, will be merged together to reduce polygon count.
When is , the method used to rotate the as it is extruded.
When is , if true the of the is used as the starting point for the extrusions, not the of the .
When is , by default, the top half of the is stretched along the entire length of the extruded shape. If false the top half of the material is repeated every step of the extrusion.
When is , this is the distance along the path, in meters, the texture coordinates will tile. When set to 0, texture coordinates will match geometry exactly with no tiling.
When is , if true the ends of the path are joined, by adding an extrusion between the last and first points of the path.
If true, applies smooth shading to the extrusions.
Material to use for the resulting mesh. The UV maps the top half of the material to the extruded shape (U along the the length of the extrusions and V around the outline of the ), the bottom-left quarter to the front end face, and the bottom-right quarter to the back end face.
Parent class for various CSG primitives. It contains code and functionality that is common between them. It cannot be used directly. Instead use one of the various classes that inherit from it.
Note: CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a with a . Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
Invert the faces of the mesh.
This is the CSG base class that provides CSG operation support to the various CSG nodes in Godot.
Note: CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a with a . Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
Geometry of both primitives is merged, intersecting geometry is removed.
Only intersecting geometry remains, the rest is removed.
The second shape is subtracted from the first, leaving a dent with its shape.
The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent.
Snap makes the mesh snap to a given distance so that the faces of two meshes can be perfectly aligned. A lower value results in greater precision but may be harder to adjust.
Calculate tangents for the CSG shape which allows the use of normal maps. This is only applied on the root shape, this setting is ignored on any child.
Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden.
The physics layers this area is in.
Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See Collision layers and masks in the documentation for more information.
The physics layers this CSG shape scans for collisions. See Collision layers and masks in the documentation for more information.
Returns true if this is a root shape and is thus the object that is rendered.
Sets individual bits on the collision mask. Use this if you only need to change one layer's value.
Returns an individual bit on the collision mask.
Sets individual bits on the layer mask. Use this if you only need to change one layer's value.
Returns an individual bit on the collision mask.
Returns an with two elements, the first is the of this node and the second is the root of this node. Only works when this node is the root shape.
This node allows you to create a sphere for use with the CSG system.
Note: CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a with a . Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
Radius of the sphere.
Number of vertical slices for the sphere.
Number of horizontal slices for the sphere.
If true the normals of the sphere are set to give a smooth effect making the sphere seem rounded. If false the sphere will have a flat shaded look.
The material used to render the sphere.
This node allows you to create a torus for use with the CSG system.
Note: CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a with a . Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
The inner radius of the torus.
The outer radius of the torus.
The number of slices the torus is constructed of.
The number of edges each ring of the torus is constructed of.
If true the normals of the torus are set to give a smooth effect making the torus seem rounded. If false the torus will have a flat shaded look.
The material used to render the torus.
This class represents a C# script. It is the C# equivalent of the class and is only available in Mono-enabled Godot builds.
See also .
Returns a new instance of the script.
is used to call a method in a tweening sequence. See for more usage information.
Note: is the only correct way to create . Any created manually will not function correctly.
Makes the callback call delayed by given time in seconds. Example:
var tween = get_tree().create_tween()
tween.tween_callback(queue_free).set_delay(2) #this will call queue_free() after 2 seconds
Camera is a special node that displays what is visible from its current location. Cameras register themselves in the nearest node (when ascending the tree). Only one camera can be active per viewport. If no viewport is available ascending the tree, the camera will register in the global viewport. In other words, a camera just provides 3D display capabilities to a , and, without one, a scene registered in that (or higher viewports) can't be displayed.
Preserves the horizontal aspect ratio; also known as Vert- scaling. This is usually the best option for projects running in portrait mode, as taller aspect ratios will benefit from a wider vertical FOV.
Preserves the vertical aspect ratio; also known as Hor+ scaling. This is usually the best option for projects running in landscape mode, as wider aspect ratios will automatically benefit from a wider horizontal FOV.
Perspective projection. Objects on the screen becomes smaller when they are far away.
Orthogonal projection, also known as orthographic projection. Objects remain the same size on the screen no matter how far away they are.
Frustum projection. This mode allows adjusting to create "tilted frustum" effects.
Disables Doppler effect simulation (default).
Simulate Doppler effect by tracking positions of objects that are changed in _process. Changes in the relative velocity of this camera compared to those objects affect how audio is perceived (changing the audio's ).
Simulate Doppler effect by tracking positions of objects that are changed in _physics_process. Changes in the relative velocity of this camera compared to those objects affect how audio is perceived (changing the audio's ).
The axis to lock during / adjustments. Can be either or .
The culling mask that describes which 3D render layers are rendered by this camera.
The to use for this camera.
The horizontal (X) offset of the camera viewport.
The vertical (Y) offset of the camera viewport.
If not , this camera will simulate the Doppler effect for objects changed in particular _process methods. The Doppler effect is only simulated for nodes that have set to a value other than .
Note: To toggle the Doppler effect preview in the editor, use the Perspective menu in the top-left corner of the 3D viewport and toggle Enable Doppler.
The camera's projection mode. In mode, objects' Z distance from the camera's local space scales their perceived size.
If true, the ancestor is currently using this camera.
If multiple cameras are in the scene, one will always be made current. For example, if two nodes are present in the scene and only one is current, setting one camera's to false will cause the other camera to be made current.
The camera's field of view angle (in degrees). Only applicable in perspective mode. Since locks one axis, fov sets the other axis' field of view angle.
For reference, the default vertical field of view value (70.0) is equivalent to a horizontal FOV of:
- ~86.07 degrees in a 4:3 viewport
- ~96.50 degrees in a 16:10 viewport
- ~102.45 degrees in a 16:9 viewport
- ~117.06 degrees in a 21:9 viewport
The camera's size in meters measured as the diameter of the width or height, depending on . Only applicable in orthogonal and frustum modes.
The camera's frustum offset. This can be changed from the default to create "tilted frustum" effects such as Y-shearing.
Note: Only effective if is .
The distance to the near culling boundary for this camera relative to its local Z axis.
The distance to the far culling boundary for this camera relative to its local Z axis.
Returns a normal vector in world space, that is the result of projecting a point on the rectangle by the inverse camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking.
Returns a normal vector from the screen point location directed along the camera. Orthogonal cameras are normalized. Perspective cameras account for perspective, screen width/height, etc.
Returns a 3D position in world space, that is the result of projecting a point on the rectangle by the inverse camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking.
Returns the 2D coordinate in the rectangle that maps to the given 3D point in world space.
Note: When using this to position GUI elements over a 3D viewport, use to prevent them from appearing if the 3D point is behind the camera:
# This code block is part of a script that inherits from Spatial.
# `control` is a reference to a node inheriting from Control.
control.visible = not get_viewport().get_camera().is_position_behind(global_transform.origin)
control.rect_position = get_viewport().get_camera().unproject_position(global_transform.origin)
Returns true if the given position is behind the camera.
Note: A position which returns false may still be outside the camera's field of view.
Returns the 3D point in world space that maps to the given 2D coordinate in the rectangle on a plane that is the given z_depth distance into the scene away from the camera.
Sets the camera projection to perspective mode (see ), by specifying a fov (field of view) angle in degrees, and the z_near and z_far clip planes in world space units.
Sets the camera projection to orthogonal mode (see ), by specifying a size, and the z_near and z_far clip planes in world space units. (As a hint, 2D games often use this projection, with values specified in pixels.)
Sets the camera projection to frustum mode (see ), by specifying a size, an offset, and the z_near and z_far clip planes in world space units. See also .
Makes this camera the current camera for the (see class description). If the camera node is outside the scene tree, it will attempt to become current once it's added.
If this is the current camera, remove it from being current. If enable_next is true, request to make the next camera current, if any.
Returns the transform of the camera plus the vertical () and horizontal () offsets; and any other adjustments made to the position and orientation of the camera by subclassed cameras such as , and .
Returns the camera's frustum planes in world space units as an array of s in the following order: near, far, left, top, right, bottom. Not to be confused with .
Returns the camera's RID from the .
Enables or disables the given layer in the .
Returns true if the given layer in the is enabled, false otherwise.
Camera node for 2D scenes. It forces the screen (current layer) to scroll following this node. This makes it easier (and faster) to program scrollable scenes than manually changing the position of -based nodes.
This node is intended to be a simple helper to get things going quickly, but more functionality may be desired to change how the camera works. To make your own custom camera node, inherit it from and change the transform of the canvas by setting in (you can obtain the current by using ).
Note that the node's position doesn't represent the actual position of the screen, which may differ due to applied smoothing or limits. You can use to get the real position.
The camera updates with the _physics_process callback.
The camera updates with the _process callback.
The camera's position is fixed so that the top-left corner is always at the origin.
The camera's position takes into account vertical/horizontal offsets and the screen size.
The camera's offset, useful for looking around or camera shake animations.
The Camera2D's anchor point. See constants.
If true, the camera view rotates with the target.
If true, the camera is the active camera for the current scene. Only one camera can be current, so setting a different camera current will disable this one.
The camera's zoom relative to the viewport. Values larger than Vector2(1, 1) zoom out and smaller values zoom in. For an example, use Vector2(0.5, 0.5) for a 2× zoom-in, and Vector2(4, 4) for a 4× zoom-out.
The custom node attached to the . If null or not a , uses the default viewport instead.
The camera's process callback. See .
Left scroll limit in pixels. The camera stops moving when reaching this value.
Top scroll limit in pixels. The camera stops moving when reaching this value.
Right scroll limit in pixels. The camera stops moving when reaching this value.
Bottom scroll limit in pixels. The camera stops moving when reaching this value.
If true, the camera smoothly stops when reaches its limits.
This property has no effect if is false.
Note: To immediately update the camera's position to be within limits without smoothing, even with this setting enabled, invoke .
If true, the camera only moves when reaching the horizontal drag margins. If false, the camera moves horizontally regardless of margins.
If true, the camera only moves when reaching the vertical drag margins. If false, the camera moves vertically regardless of margins.
If true, the camera smoothly moves towards the target at .
Speed in pixels per second of the camera's smoothing effect when is true.
The horizontal offset of the camera, relative to the drag margins.
Note: Offset H is used only to force offset relative to margins. It's not updated in any way if drag margins are enabled and can be used to set initial offset.
The vertical offset of the camera, relative to the drag margins.
Note: Used the same as .
Left margin needed to drag the camera. A value of 1 makes the camera move only when reaching the edge of the screen.
Top margin needed to drag the camera. A value of 1 makes the camera move only when reaching the edge of the screen.
Right margin needed to drag the camera. A value of 1 makes the camera move only when reaching the edge of the screen.
Bottom margin needed to drag the camera. A value of 1 makes the camera move only when reaching the edge of the screen.
If true, draws the camera's screen rectangle in the editor.
If true, draws the camera's limits rectangle in the editor.
If true, draws the camera's drag margin rectangle in the editor.
Make this the current 2D camera for the scene (viewport and layer), in case there are many cameras in the scene.
Removes any from the ancestor 's internal currently-assigned camera.
Sets the specified camera limit. See also , , , and .
Returns the specified camera limit. See also , , , and .
Sets the specified margin. See also , , , and .
Returns the specified margin. See also , , , and .
Returns the camera's position (the tracked point the camera attempts to follow), relative to the origin.
Note: The returned value is not the same as or , as it is affected by the drag properties.
Returns the location of the 's screen-center, relative to the origin.
Note: The real position of the camera may be different, see .
Forces the camera to update scroll immediately.
Sets the camera's position immediately to its current smoothing destination.
This method has no effect if is false.
Aligns the camera to the tracked node.
A camera feed gives you access to a single physical camera attached to your device. When enabled, Godot will start capturing frames from the camera which can then be used. See also .
Note: Many cameras will return YCbCr images which are split into two textures and need to be combined in a shader. Godot does this automatically for you if you set the environment to show the camera image in the background.
No image set for the feed.
Feed supplies RGB images.
Feed supplies YCbCr images that need to be converted to RGB.
Feed supplies separate Y and CbCr images that need to be combined and converted to RGB.
Unspecified position.
Camera is mounted at the front of the device.
Camera is mounted at the back of the device.
If true, the feed is active.
The transform applied to the camera's image.
Returns the unique ID for this feed.
Returns the camera's name.
Returns the position of camera on the device.
The keeps track of different cameras accessible in Godot. These are external cameras such as webcams or the cameras on your phone.
It is notably used to provide AR modules with a video feed from the camera.
Note: This class is currently only implemented on macOS and iOS. On other platforms, no s will be available.
The RGBA camera image.
The YCbCr camera image.
The Y component camera image.
The CbCr component camera image.
Returns the corresponding to the camera with the given index.
Returns the number of s registered.
Returns an array of s.
Adds the camera feed to the camera server.
Removes the specified camera feed.
This texture gives access to the camera texture provided by a .
Note: Many cameras supply YCbCr images which need to be converted in a shader.
The ID of the for which we want to display the image.
Which image within the we want access to, important if the camera image is split in a Y and CbCr component.
Convenience property that gives access to the active property of the .
Base class of anything 2D. Canvas items are laid out in a tree; children inherit and extend their parent's transform. is extended by for anything GUI-related, and by for anything related to the 2D engine.
Any can draw. For this, is called by the engine, then will be received on idle time to request redraw. Because of this, canvas items don't need to be redrawn on every frame, improving the performance significantly. Several functions for drawing on the are provided (see draw_* functions). However, they can only be used inside , its corresponding or methods connected to the draw signal.
Canvas items are drawn in tree order. By default, children are on top of their parents so a root will be drawn behind everything. This behavior can be changed on a per-item basis.
A can also be hidden, which will also hide its children. It provides many ways to change parameters such as modulation (for itself and its children) and self modulation (only for itself), as well as its blend mode.
Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed.
Note: Unless otherwise specified, all methods that have angle parameters must have angles specified as radians. To convert degrees to radians, use @GDScript.deg2rad.
The 's global transform has changed. This notification is only received if enabled by .
The 's local transform has changed. This notification is only received if enabled by .
The is requested to draw (see ).
The 's visibility has changed.
The has entered the canvas.
The has exited the canvas.
Mix blending mode. Colors are assumed to be independent of the alpha (opacity) value.
Additive blending mode.
Subtractive blending mode.
Multiplicative blending mode.
Mix blending mode. Colors are assumed to be premultiplied by the alpha (opacity) value.
Disables blending mode. Colors including alpha are written as-is. Only applicable for render targets with a transparent background. No lighting will be applied.
If true, this is drawn. The node is only visible if all of its antecedents are visible as well (in other words, must return true).
Note: For controls that inherit , the correct way to make them visible is to call one of the multiple popup*() functions instead.
The color applied to textures on this .
The color applied to textures on this . This is not inherited by children s.
If true, the object draws behind its parent.
If true, the object draws on top of its parent.
The rendering layers in which this responds to nodes.
The material applied to textures on this .
If true, the parent 's property is used as this one's material.
Called when has been requested to redraw (when is called, either manually or by the engine).
Corresponds to the notification in .
Returns the canvas item RID used by for this item.
Returns true if the node is present in the , its property is true and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree, and is consequently not drawn (see ).
Show the if it's currently hidden. This is equivalent to setting to true. For controls that inherit , the correct way to make them visible is to call one of the multiple popup*() functions instead.
Hide the if it's currently visible. This is equivalent to setting to false.
Queues the to redraw. During idle time, if is visible, is sent and is called. This only occurs once per frame, even if this method has been called multiple times.
If enable is true, this will not inherit its transform from parent s. Its draw order will also be changed to make it draw on top of other s that are not set as top-level. The will effectively act as if it was placed as a child of a bare . See also .
Returns true if the node is set as top-level. See .
Draws a line from a 2D point to another, with a given color and width. It can be optionally antialiased. See also and .
Note: Line drawing is not accelerated by batching if antialiased is true.
Note: Due to how it works, built-in antialiasing will not look correct for translucent lines and may not work on certain platforms. As a workaround, install the Antialiased Line2D add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
Draws interconnected line segments with a uniform color and width and optional antialiasing. When drawing large amounts of lines, this is faster than using individual calls. To draw disconnected lines, use instead. See also .
Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the Antialiased Line2D add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
Draws interconnected line segments with a uniform width and segment-by-segment coloring, and optional antialiasing. Colors assigned to line segments match by index between points and colors. When drawing large amounts of lines, this is faster than using individual calls. To draw disconnected lines, use instead. See also .
Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the Antialiased Line2D add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
Draws a unfilled arc between the given angles. The larger the value of point_count, the smoother the curve. See also .
Note: Line drawing is not accelerated by batching if antialiased is true.
Note: Due to how it works, built-in antialiasing will not look correct for translucent lines and may not work on certain platforms. As a workaround, install the Antialiased Line2D add-on then create an AntialiasedRegularPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
Draws multiple disconnected lines with a uniform color. When drawing large amounts of lines, this is faster than using individual calls. To draw interconnected lines, use instead.
Note: width and antialiased are currently not implemented and have no effect. As a workaround, install the Antialiased Line2D add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
Draws multiple disconnected lines with a uniform width and segment-by-segment coloring. Colors assigned to line segments match by index between points and colors. When drawing large amounts of lines, this is faster than using individual calls. To draw interconnected lines, use instead.
Note: width and antialiased are currently not implemented and have no effect. As a workaround, install the Antialiased Line2D add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
Draws a rectangle. If filled is true, the rectangle will be filled with the color specified. If filled is false, the rectangle will be drawn as a stroke with the color and width specified. If antialiased is true, the lines will attempt to perform antialiasing using OpenGL line smoothing.
Note: width and antialiased are only effective if filled is false.
Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the Antialiased Line2D add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
Draws a colored, filled circle. See also , and .
Note: Built-in antialiasing is not provided for . As a workaround, install the Antialiased Line2D add-on then create an AntialiasedRegularPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
Draws a texture at a given position.
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Draws a textured rectangle at a given position, optionally modulated by a color. If transpose is true, the texture will have its X and Y coordinates swapped.
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Draws a textured rectangle region at a given position, optionally modulated by a color. If transpose is true, the texture will have its X and Y coordinates swapped.
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Draws a styled rectangle.
Draws a custom primitive. 1 point for a point, 2 points for a line, 3 points for a triangle, and 4 points for a quad. If 0 points or more than 4 points are specified, nothing will be drawn and an error message will be printed. See also , , , and .
Draws a solid polygon of any amount of points, convex or concave. Unlike , each point's color can be changed individually. See also and .
Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the Antialiased Line2D add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
If the parameter is null, then the default value is Array.Empty<Vector2>()
Draws a colored polygon of any amount of points, convex or concave. Unlike , a single color must be specified for the whole polygon.
Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the Antialiased Line2D add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
If the parameter is null, then the default value is Array.Empty<Vector2>()
Draws text using the specified font at the position (bottom-left corner using the baseline of the font). The text will have its color multiplied by modulate. If clip_w is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
Example using the default project font:
# If using this method in a script that redraws constantly, move the
# `default_font` declaration to a member variable assigned in `_ready()`
# so the Control is only created once.
var default_font = Control.new().get_font("font")
draw_string(default_font, Vector2(64, 64), "Hello world")
See also .
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Draws a string character using a custom font. Returns the advance, depending on the character width and kerning with an optional next character.
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Draws a in 2D, using the provided texture. See for related documentation.
If the parameter is null, then the default value is Transform2D.Identity
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Draws a in 2D with the provided texture. See for related documentation.
Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this.
Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this.
Returns the transform matrix of this item.
Returns the global transform matrix of this item.
Returns the global transform matrix of this item in relation to the canvas.
Returns this item's transform in relation to the viewport.
Returns the viewport's boundaries as a .
Returns the transform matrix of this item's canvas.
Returns the mouse's position in this using the local coordinate system of this .
Returns the mouse's position in the that this is in using the coordinate system of the .
Returns the of the canvas where this item is in.
Returns the where this item is in.
If enable is true, this node will receive when its local transform changes.
Returns true if local transform notifications are communicated to children.
If enable is true, this node will receive when its global transform changes.
Returns true if global transform notifications are communicated to children.
Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations.
Assigns screen_point as this node's new local transform.
Transformations issued by event's inputs are applied in local space instead of global space.
s provide a means of modifying the textures associated with a CanvasItem. They specialize in describing blend and lighting behaviors for textures. Use a to more fully customize a material's interactions with a .
Render the material using both light and non-light sensitive material properties.
Render the material as if there were no light.
Render the material as if there were only light.
Mix blending mode. Colors are assumed to be independent of the alpha (opacity) value.
Additive blending mode.
Subtractive blending mode.
Multiplicative blending mode.
Mix blending mode. Colors are assumed to be premultiplied by the alpha (opacity) value.
The manner in which a material's rendering is applied to underlying textures.
The manner in which material reacts to lighting.
If true, enable spritesheet-based animation features when assigned to and nodes. The or should also be set to a positive value for the animation to play.
This property (and other particles_anim_* properties that depend on it) has no effect on other types of nodes.
The number of columns in the spritesheet assigned as for a or .
Note: This property is only used and visible in the editor if is true.
The number of rows in the spritesheet assigned as for a or .
Note: This property is only used and visible in the editor if is true.
If true, the particles animation will loop.
Note: This property is only used and visible in the editor if is true.
Canvas drawing layer. nodes that are direct or indirect children of a will be drawn in that layer. The layer is a numeric index that defines the draw order. The default 2D scene renders with index 0, so a with index -1 will be drawn below, and one with index 1 will be drawn above. This is very useful for HUDs (in layer 1+ or above), or backgrounds (in layer -1 or below).
Layer index for draw order. Lower values are drawn first.
If false, any under this will be hidden.
Unlike , visibility of a isn't propagated to underlying layers.
The layer's base offset.
The layer's rotation in degrees.
The layer's rotation in radians.
The layer's scale.
The layer's transform.
The custom node assigned to the . If null, uses the default viewport instead.
If enabled, the will use the viewport's transform, so it will move when camera moves instead of being anchored in a fixed position on the screen.
Together with it can be used for a pseudo 3D effect.
Scales the layer when using . Layers moving into the foreground should have increasing scales, while layers moving into the background should have decreasing scales.
Shows any under this . This is equivalent to setting to true.
Hides any under this . This is equivalent to setting to false.
Returns the RID of the canvas used by this layer.
tints the canvas elements using its assigned .
The tint color to apply.
Class representing a capsule-shaped .
Radius of the capsule mesh.
Height of the middle cylindrical part of the capsule (without the hemispherical ends).
Note: The capsule's total height is equal to + 2 * .
Number of radial segments on the capsule mesh.
Number of rings along the height of the capsule.
Capsule shape for collisions.
The capsule's radius.
The capsule's height.
Capsule shape for 2D collisions.
The capsule's radius.
The capsule's height.
CenterContainer keeps children controls centered. This container keeps all children to their minimum size, in the center.
If true, centers children relative to the 's top left corner.
By setting various properties on this object, you can control how individual characters will be displayed in a .
The index of the current character (starting from 0) for this custom block. Setting this property won't affect drawing.
The index of the current character (starting from 0) for the 's BBCode text. Setting this property won't affect drawing.
The time elapsed since the was added to the scene tree (in seconds). Time stops when the is paused (see ). Resets when the text in the is changed.
Note: Time still passes while the is hidden.
If true, the character will be drawn. If false, the character will be hidden. Characters around hidden characters will reflow to take the space of hidden characters. If this is not desired, set their to Color(1, 1, 1, 0) instead.
The position offset the character will be drawn with (in pixels).
The color the character will be drawn with.
Contains the arguments passed in the opening BBCode tag. By default, arguments are strings; if their contents match a type such as , or , they will be converted automatically. Color codes in the form #rrggbb or #rgb will be converted to an opaque . String arguments may not contain spaces, even if they're quoted. If present, quotes will also be present in the final string.
For example, the opening BBCode tag [example foo=hello bar=true baz=42 color=#ffffff] will map to the following :
{"foo": "hello", "bar": true, "baz": 42, "color": Color(1, 1, 1, 1)}
The Unicode codepoint the character will use. This only affects non-whitespace characters. @GDScript.ord can be useful here. For example, the following will replace all characters with asterisks:
# `char_fx` is the CharFXTransform parameter from `_process_custom_fx()`.
# See the RichTextEffect documentation for details.
char_fx.character = ord("*")
A checkbox allows the user to make a binary choice (choosing only one of two possible options). It's similar to in functionality, but it has a different appearance. To follow established UX patterns, it's recommended to use CheckBox when toggling it has no immediate effect on something. For instance, it should be used when toggling it will only do something once a confirmation button is pressed.
See also which contains common properties and methods associated with this node.
CheckButton is a toggle button displayed as a check field. It's similar to in functionality, but it has a different appearance. To follow established UX patterns, it's recommended to use CheckButton when toggling it has an immediate effect on something. For instance, it should be used if toggling it enables/disables a setting without requiring the user to press a confirmation button.
See also which contains common properties and methods associated with this node.
Circular shape for 2D collisions. This shape is useful for modeling balls or small characters and its collision detection with everything else is very fast.
The circle's radius.
This node extends to add collisions with and/or nodes. The camera cannot move through colliding objects.
The camera updates with the _physics_process callback.
The camera updates with the _process callback.
The camera's collision margin. The camera can't get closer than this distance to a colliding object.
The camera's process callback. See .
The camera's collision mask. Only objects in at least one collision layer matching the mask will be detected. See Collision layers and masks in the documentation for more information.
If true, the camera stops on contact with s.
If true, the camera stops on contact with s.
Sets the specified bit index to the value.
Note: Bit indices range from 0-19.
Returns true if the specified bit index is on.
Note: Bit indices range from 0-19.
Adds a collision exception so the camera does not collide with the specified .
Adds a collision exception so the camera does not collide with the specified node.
Removes a collision exception with the specified .
Removes a collision exception with the specified node.
Returns the distance the camera has been offset due to a collision.
Removes all collision exceptions.
CollisionObject is the base class for physics objects. It can hold any number of collision s. Each shape must be assigned to a shape owner. The CollisionObject can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the shape_owner_* methods.
The physics layers this CollisionObject3D is in. Collision objects can exist in one or more of 32 different layers. See also .
Note: A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See Collision layers and masks in the documentation for more information.
The physics layers this CollisionObject3D scans. Collision objects can scan one or more of 32 different layers. See also .
Note: A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See Collision layers and masks in the documentation for more information.
If true, this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one bit to be set.
If true, the will continue to receive input events as the mouse is dragged across its shapes.
Receives unhandled s. position is the location in world space of the mouse pointer on the surface of the shape with index shape_idx and normal is the normal vector of the surface at that point. Connect to the input_event signal to easily pick up these events.
If value is true, sets the specified bit in the .
If value is false, clears the specified bit in the .
Returns whether or not the specified bit of the is set.
If value is true, sets the specified bit in the .
If value is false, clears the specified bit in the .
Returns whether or not the specified bit of the is set.
Returns the object's .
Creates a new shape owner for the given object. Returns owner_id of the new owner for future reference.
Removes the given shape owner.
Returns an of owner_id identifiers. You can use these ids in other methods that take owner_id as an argument.
Sets the of the given shape owner.
Returns the shape owner's .
Returns the parent object of the given shape owner.
If true, disables the given shape owner.
If true, the shape owner and its shapes are disabled.
Adds a to the shape owner.
Returns the number of shapes the given shape owner contains.
Returns the with the given id from the given shape owner.
Returns the child index of the with the given id from the given shape owner.
Removes a shape from the given shape owner.
Removes all shapes from the shape owner.
Returns the owner_id of the given shape.
CollisionObject2D is the base class for 2D physics objects. It can hold any number of 2D collision s. Each shape must be assigned to a shape owner. The CollisionObject2D can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the shape_owner_* methods.
Note: Only collisions between objects within the same canvas ( canvas or ) are supported. The behavior of collisions between objects in different canvases is undefined.
The physics layers this CollisionObject2D is in. Collision objects can exist in one or more of 32 different layers. See also .
Note: A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See Collision layers and masks in the documentation for more information.
The physics layers this CollisionObject2D scans. Collision objects can scan one or more of 32 different layers. See also .
Note: A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See Collision layers and masks in the documentation for more information.
If true, this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one bit to be set.
Accepts unhandled s. Requires to be true. shape_idx is the child index of the clicked . Connect to the input_event signal to easily pick up these events.
Returns the object's .
If value is true, sets the specified bit in the .
If value is false, clears the specified bit in the .
Returns whether or not the specified bit of the is set.
If value is true, sets the specified bit in the .
If value is false, clears the specified bit in the .
Returns whether or not the specified bit of the is set.
Creates a new shape owner for the given object. Returns owner_id of the new owner for future reference.
Removes the given shape owner.
Returns an of owner_id identifiers. You can use these ids in other methods that take owner_id as an argument.
Sets the of the given shape owner.
Returns the shape owner's .
Returns the parent object of the given shape owner.
If true, disables the given shape owner.
If true, the shape owner and its shapes are disabled.
If enable is true, collisions for the shape owner originating from this will not be reported to collided with s.
Returns true if collisions for the shape owner originating from this will not be reported to collided with s.
Sets the one_way_collision_margin of the shape owner identified by given owner_id to margin pixels.
Returns the one_way_collision_margin of the shape owner identified by given owner_id.
Adds a to the shape owner.
Returns the number of shapes the given shape owner contains.
Returns the with the given id from the given shape owner.
Returns the child index of the with the given id from the given shape owner.
Removes a shape from the given shape owner.
Removes all shapes from the shape owner.
Returns the owner_id of the given shape.
Allows editing a collision polygon's vertices on a selected plane. Can also set a depth perpendicular to that plane. This class is only available in the editor. It will not appear in the scene tree at run-time. Creates a for gameplay. Properties modified during gameplay will have no effect.
Length that the resulting collision extends in either direction perpendicular to its polygon.
If true, no collision will be produced.
Array of vertices which define the polygon.
Note: The returned value is a copy of the original. Methods which mutate the size or properties of the return value will not impact the original polygon. To change properties of the polygon, assign it to a temporary variable and make changes before reassigning the polygon member.
The collision margin for the generated . See for more details.
Provides a 2D collision polygon to a parent. Polygons can be drawn in the editor or specified by a list of vertices.
Collisions will include the polygon and its contained area.
Collisions will only include the polygon edges.
Collision build mode. Use one of the constants.
The polygon's list of vertices. The final point will be connected to the first. The returned value is a clone of the , not a reference.
If true, no collisions will be detected.
If true, only edges that face up, relative to 's rotation, will collide with other objects.
Note: This property has no effect if this is a child of an node.
The margin used for one-way collision (in pixels). Higher values will make the shape thicker, and work better for colliders that enter the polygon at a high velocity.
Editor facility for creating and editing collision shapes in 3D space. Set the property to configure the shape. IMPORTANT: this is an Editor-only helper to create shapes, use to get the actual shape.
You can use this node to represent all sorts of collision shapes, for example, add this to an to give it a detection shape, or add it to a to create a solid object.
The actual shape owned by this collision shape.
A disabled collision shape has no effect in the world.
If this method exists within a script it will be called whenever the shape resource has been modified.
Sets the collision shape's shape to the addition of all its convexed siblings geometry.
Editor facility for creating and editing collision shapes in 2D space. Set the property to configure the shape. IMPORTANT: this is an Editor-only helper to create shapes, use to get the actual shape.
You can use this node to represent all sorts of collision shapes, for example, add this to an to give it a detection shape, or add it to a to create a solid object.
The actual shape owned by this collision shape.
A disabled collision shape has no effect in the world. This property should be changed with .
Sets whether this collision shape should only detect collision on one side (top or bottom).
Note: This property has no effect if this is a child of an node.
The margin used for one-way collision (in pixels). Higher values will make the shape thicker, and work better for colliders that enter the shape at a high velocity.
Displays a color picker widget. Useful for selecting a color from an RGB/RGBA colorspace.
Note: This control is the color picker widget itself. You can use a instead if you need a button that brings up a in a pop-up.
The currently selected color.
If true, shows an alpha channel slider (opacity).
If true, allows editing the color with Hue/Saturation/Value sliders.
Note: Cannot be enabled if raw mode is on.
If true, allows the color R, G, B component values to go beyond 1.0, which can be used for certain special operations that require it (like tinting without darkening or rendering sprites in HDR).
Note: Cannot be enabled if HSV mode is on.
If true, the color will apply only after the user releases the mouse button, otherwise it will apply immediately even in mouse motion event (which can cause performance issues).
If true, the "add preset" button is enabled.
If true, saved color presets are visible.
Adds the given color to a list of color presets. The presets are displayed in the color picker and the user will be able to select them.
Note: The presets list is only for this color picker.
Removes the given color from the list of color presets of this color picker.
Returns the list of colors in the presets of the color picker.
Encapsulates a making it accessible by pressing a button. Pressing the button will toggle the visibility.
See also which contains common properties and methods associated with this node.
Note: By default, the button may not be wide enough for the color preview swatch to be visible. Make sure to set to a big enough value to give the button enough space.
The currently selected color.
If true, the alpha channel in the displayed will be visible.
Returns the that this node toggles.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Returns the control's which allows you to connect to popup signals. This allows you to handle events when the ColorPicker is shown or hidden.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Displays a rectangle filled with a solid . If you need to display the border alone, consider using instead.
The fill color.
$ColorRect.color = Color(1, 0, 0, 1) # Set ColorRect's color to red.
Concave polygon shape resource, which can be set into a or area. This shape is created by feeding a list of triangles.
Note: When used for collision, is intended to work with static nodes like and will not work with or with a mode other than Static.
Warning: Using this shape for an (via a node, created e.g. by using the Create Trimesh Collision Sibling option in the Mesh menu that appears when selecting a node) may give unexpected results: when using Godot Physics, the area will only detect collisions with the triangle faces in the (and not with any "inside" of the shape, for example), and when using Bullet Physics the area will not detect any collisions with the concave shape at all (this is a known bug).
Sets the faces (an array of triangles).
Returns the faces (an array of triangles).
Concave polygon 2D shape resource for physics. It is made out of segments and is optimal for complex polygonal concave collisions. However, it is not advised to use for nodes. A CollisionPolygon2D in convex decomposition mode (solids) or several convex objects are advised for that instead. Otherwise, a concave polygon 2D shape is better for static collisions.
The main difference between a and a is that a concave polygon assumes it is concave and uses a more complex method of collision detection, and a convex one forces itself to be convex in order to speed up collision detection.
Warning: Using this shape for an (via a node) may give unexpected results: the area will only detect collisions with the segments in the (and not with any "inside" of the shape, for example).
The array of points that make up the 's line segments.
The joint can rotate the bodies across an axis defined by the local x-axes of the .
The twist axis is initiated as the X axis of the .
Once the Bodies swing, the twist axis is calculated as the middle of the x-axes of the Joint in the local space of the two Bodies. See also .
Swing is rotation from side to side, around the axis perpendicular to the twist axis.
The swing span defines, how much rotation will not get corrected along the swing axis.
Could be defined as looseness in the .
If below 0.05, this behavior is locked.
Twist is the rotation around the twist axis, this value defined how far the joint can twist.
Twist is locked if below 0.05.
The speed with which the swing or twist will take place.
The higher, the faster.
The ease with which the joint starts to twist. If it's too low, it takes more force to start twisting the joint.
Defines, how fast the swing- and twist-speed-difference on both sides gets synced.
Represents the size of the enum.
Swing is rotation from side to side, around the axis perpendicular to the twist axis.
The swing span defines, how much rotation will not get corrected along the swing axis.
Could be defined as looseness in the .
If below 0.05, this behavior is locked.
Twist is the rotation around the twist axis, this value defined how far the joint can twist.
Twist is locked if below 0.05.
The speed with which the swing or twist will take place.
The higher, the faster.
The ease with which the joint starts to twist. If it's too low, it takes more force to start twisting the joint.
Defines, how fast the swing- and twist-speed-difference on both sides gets synced.
This helper class can be used to store Variant values on the filesystem using INI-style formatting. The stored values are identified by a section and a key:
[section]
some_key=42
string_example="Hello World!"
a_vector=Vector3( 1, 0, 2 )
The stored data can be saved to or parsed from a file, though ConfigFile objects can also be used directly without accessing the filesystem.
The following example shows how to create a simple and save it on disk:
# Create new ConfigFile object.
var config = ConfigFile.new()
# Store some values.
config.set_value("Player1", "player_name", "Steve")
config.set_value("Player1", "best_score", 10)
config.set_value("Player2", "player_name", "V3geta")
config.set_value("Player2", "best_score", 9001)
# Save it to a file (overwrite if already exists).
config.save("user://scores.cfg")
This example shows how the above file could be loaded:
var score_data = {}
var config = ConfigFile.new()
# Load data from a file.
var err = config.load("user://scores.cfg")
# If the file didn't load, ignore it.
if err != OK:
return
# Iterate over all sections.
for player in config.get_sections():
# Fetch the data for each section.
var player_name = config.get_value(player, "player_name")
var player_score = config.get_value(player, "best_score")
score_data[player_name] = player_score
Any operation that mutates the ConfigFile such as , , or , only changes what is loaded in memory. If you want to write the change to a file, you have to save the changes with , , or .
Keep in mind that section and property names can't contain spaces. Anything after a space will be ignored on save and on load.
ConfigFiles can also contain manually written comment lines starting with a semicolon (;). Those lines will be ignored when parsing the file. Note that comments will be lost when saving the ConfigFile. This can still be useful for dedicated server configuration files, which are typically never overwritten without explicit user action.
Note: The file extension given to a ConfigFile does not have any impact on its formatting or behavior. By convention, the .cfg extension is used here, but any other extension such as .ini is also valid. Since neither .cfg nor .ini are standardized, Godot's ConfigFile formatting may differ from files written by other programs.
Assigns a value to the specified key of the specified section. If either the section or the key do not exist, they are created. Passing a null value deletes the specified key if it exists, and deletes the section if it ends up empty once the key has been removed.
Returns the current value for the specified section and key. If either the section or the key do not exist, the method returns the fallback default value. If default is not specified or set to null, an error is also raised.
Returns true if the specified section exists.
Returns true if the specified section-key pair exists.
Returns an array of all defined section identifiers.
Returns an array of all defined key identifiers in the specified section. Raises an error and returns an empty array if the section does not exist.
Deletes the specified section along with all the key-value pairs inside. Raises an error if the section does not exist.
Deletes the specified key in a section. Raises an error if either the section or the key do not exist.
Loads the config file specified as a parameter. The file's contents are parsed and loaded in the object which the method was called on.
Returns one of the code constants (OK on success).
Parses the passed string as the contents of a config file. The string is parsed and loaded in the ConfigFile object which the method was called on.
Returns one of the code constants (OK on success).
Saves the contents of the object to the file specified as a parameter. The output file uses an INI-style structure.
Returns one of the code constants (OK on success).
Loads the encrypted config file specified as a parameter, using the provided key to decrypt it. The file's contents are parsed and loaded in the object which the method was called on.
Returns one of the code constants (OK on success).
Loads the encrypted config file specified as a parameter, using the provided password to decrypt it. The file's contents are parsed and loaded in the object which the method was called on.
Returns one of the code constants (OK on success).
Saves the contents of the object to the AES-256 encrypted file specified as a parameter, using the provided key to encrypt it. The output file uses an INI-style structure.
Returns one of the code constants (OK on success).
Saves the contents of the object to the AES-256 encrypted file specified as a parameter, using the provided password to encrypt it. The output file uses an INI-style structure.
Returns one of the code constants (OK on success).
Removes the entire contents of the config.
Dialog for confirmation of actions. This dialog inherits from , but has by default an OK and Cancel button (in host OS order).
To get cancel action, you can use:
get_cancel().connect("pressed", self, "cancelled")
.
Returns the cancel button.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Base node for containers. A contains other controls and automatically arranges them in a certain way.
A Control can inherit this to create custom container classes.
Notification for when sorting the children, it must be obeyed immediately.
Queue resort of the contained children. This is called automatically anyway, but can be called upon request.
Fit a child control in a given rect. This is mainly a helper for creating custom container classes.
Base class for all UI-related nodes. features a bounding rectangle that defines its extents, an anchor position relative to its parent control or the current viewport, and margins that represent an offset to the anchor. The margins update automatically when the node, any of its parents, or the screen size change.
For more information on Godot's UI system, anchors, margins, and containers, see the related tutorials in the manual. To build flexible UIs, you'll need a mix of UI elements that inherit from and nodes.
User Interface nodes and input
Godot sends input events to the scene's root node first, by calling . forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls . Call so no other node receives the event. Once you accept an input, it becomes handled so will not process it.
Only one node can be in keyboard focus. Only the node in focus will receive keyboard events. To get the focus, call . nodes lose focus when another node grabs it, or if you hide the node in focus.
Sets to to tell a node to ignore mouse or touch events. You'll need it if you place an icon on top of a button.
resources change the Control's appearance. If you change the on a node, it affects all of its children. To override some of the theme's parameters, call one of the add_*_override methods, like . You can override the theme with the inspector.
Note: Theme items are not properties. This means you can't access their values using and . Instead, use , , , , , and the add_*_override methods provided by this class.
Sent when the node changes size. Use to get the new size.
Sent when the mouse pointer enters the node.
Sent when the mouse pointer exits the node.
Sent when the node grabs focus.
Sent when the node loses focus.
Sent when the node's changes, right before Godot redraws the control. Happens when you call one of the add_*_override methods.
Sent when an open modal dialog closes. See .
Sent when this node is inside a which has begun being scrolled.
Sent when this node is inside a which has stopped being scrolled.
Snaps one of the 4 anchor's sides to the origin of the node's Rect, in the top left. Use it with one of the anchor_* member variables, like . To change all 4 anchors at once, use .
Snaps one of the 4 anchor's sides to the end of the node's Rect, in the bottom right. Use it with one of the anchor_* member variables, like . To change all 4 anchors at once, use .
The node cannot grab focus. Use with .
The node can only grab focus on mouse clicks. Use with .
The node can grab focus on mouse click or using the arrows and the Tab keys on the keyboard. Use with .
The control will be resized to its minimum size.
The control's width will not change.
The control's height will not change.
The control's size will not change.
The control will receive mouse button input events through if clicked on. And the control will receive the mouse_entered and mouse_exited signals. These events are automatically marked as handled, and they will not propagate further to other controls. This also results in blocking signals in other controls.
The control will receive mouse button input events through if clicked on. And the control will receive the mouse_entered and mouse_exited signals. If this control does not handle the event, the parent control (if any) will be considered, and so on until there is no more parent control to potentially handle it. This also allows signals to fire in other controls. Even if no control handled it at all, the event will still be handled automatically, so unhandled input will not be fired.
The control will not receive mouse button input events through . The control will also not receive the mouse_entered nor mouse_exited signals. This will not block other controls from receiving these events or firing the signals. Ignored events will not be handled automatically.
Show the system's arrow mouse cursor when the user hovers the node. Use with .
Show the system's I-beam mouse cursor when the user hovers the node. The I-beam pointer has a shape similar to "I". It tells the user they can highlight or insert text.
Show the system's pointing hand mouse cursor when the user hovers the node.
Show the system's cross mouse cursor when the user hovers the node.
Show the system's wait mouse cursor when the user hovers the node. Often an hourglass.
Show the system's busy mouse cursor when the user hovers the node. Often an arrow with a small hourglass.
Show the system's drag mouse cursor, often a closed fist or a cross symbol, when the user hovers the node. It tells the user they're currently dragging an item, like a node in the Scene dock.
Show the system's drop mouse cursor when the user hovers the node. It can be an open hand. It tells the user they can drop an item they're currently grabbing, like a node in the Scene dock.
Show the system's forbidden mouse cursor when the user hovers the node. Often a crossed circle.
Show the system's vertical resize mouse cursor when the user hovers the node. A double-headed vertical arrow. It tells the user they can resize the window or the panel vertically.
Show the system's horizontal resize mouse cursor when the user hovers the node. A double-headed horizontal arrow. It tells the user they can resize the window or the panel horizontally.
Show the system's window resize mouse cursor when the user hovers the node. The cursor is a double-headed arrow that goes from the bottom left to the top right. It tells the user they can resize the window or the panel both horizontally and vertically.
Show the system's window resize mouse cursor when the user hovers the node. The cursor is a double-headed arrow that goes from the top left to the bottom right, the opposite of . It tells the user they can resize the window or the panel both horizontally and vertically.
Show the system's move mouse cursor when the user hovers the node. It shows 2 double-headed arrows at a 90 degree angle. It tells the user they can move a UI element freely.
Show the system's vertical split mouse cursor when the user hovers the node. On Windows, it's the same as .
Show the system's horizontal split mouse cursor when the user hovers the node. On Windows, it's the same as .
Show the system's help mouse cursor when the user hovers the node, a question mark.
The control will grow to the left or top to make up if its minimum size is changed to be greater than its current size on the respective axis.
The control will grow to the right or bottom to make up if its minimum size is changed to be greater than its current size on the respective axis.
The control will grow in both directions equally to make up if its minimum size is changed to be greater than its current size.
Tells the parent to expand the bounds of this node to fill all the available space without pushing any other node. Use with and .
Tells the parent to let this node take all the available space on the axis you flag. If multiple neighboring nodes are set to expand, they'll share the space based on their stretch ratio. See . Use with and .
Sets the node's size flags to both fill and expand. See the 2 constants above for more information.
Tells the parent to center the node in itself. It centers the control based on its bounding box, so it doesn't work with the fill or expand size flags. Use with and .
Tells the parent to align the node with its end, either the bottom or the right edge. It doesn't work with the fill or expand size flags. Use with and .
Snap all 4 anchors to the top-left of the parent control's bounds. Use with .
Snap all 4 anchors to the top-right of the parent control's bounds. Use with .
Snap all 4 anchors to the bottom-left of the parent control's bounds. Use with .
Snap all 4 anchors to the bottom-right of the parent control's bounds. Use with .
Snap all 4 anchors to the center of the left edge of the parent control's bounds. Use with .
Snap all 4 anchors to the center of the top edge of the parent control's bounds. Use with .
Snap all 4 anchors to the center of the right edge of the parent control's bounds. Use with .
Snap all 4 anchors to the center of the bottom edge of the parent control's bounds. Use with .
Snap all 4 anchors to the center of the parent control's bounds. Use with .
Snap all 4 anchors to the left edge of the parent control. The left margin becomes relative to the left edge and the top margin relative to the top left corner of the node's parent. Use with .
Snap all 4 anchors to the top edge of the parent control. The left margin becomes relative to the top left corner, the top margin relative to the top edge, and the right margin relative to the top right corner of the node's parent. Use with .
Snap all 4 anchors to the right edge of the parent control. The right margin becomes relative to the right edge and the top margin relative to the top right corner of the node's parent. Use with .
Snap all 4 anchors to the bottom edge of the parent control. The left margin becomes relative to the bottom left corner, the bottom margin relative to the bottom edge, and the right margin relative to the bottom right corner of the node's parent. Use with .
Snap all 4 anchors to a vertical line that cuts the parent control in half. Use with .
Snap all 4 anchors to a horizontal line that cuts the parent control in half. Use with .
Snap all 4 anchors to the respective corners of the parent control. Set all 4 margins to 0 after you applied this preset and the will fit its parent control. This is equivalent to the "Full Rect" layout option in the editor. Use with .
Anchors the left edge of the node to the origin, the center or the end of its parent control. It changes how the left margin updates when the node moves or changes size. You can use one of the constants for convenience.
Anchors the top edge of the node to the origin, the center or the end of its parent control. It changes how the top margin updates when the node moves or changes size. You can use one of the constants for convenience.
Anchors the right edge of the node to the origin, the center or the end of its parent control. It changes how the right margin updates when the node moves or changes size. You can use one of the constants for convenience.
Anchors the bottom edge of the node to the origin, the center, or the end of its parent control. It changes how the bottom margin updates when the node moves or changes size. You can use one of the constants for convenience.
Distance between the node's left edge and its parent control, based on .
Margins are often controlled by one or multiple parent nodes, so you should not modify them manually if your node is a direct child of a . Margins update automatically when you move or resize the node.
Distance between the node's top edge and its parent control, based on .
Margins are often controlled by one or multiple parent nodes, so you should not modify them manually if your node is a direct child of a . Margins update automatically when you move or resize the node.
Distance between the node's right edge and its parent control, based on .
Margins are often controlled by one or multiple parent nodes, so you should not modify them manually if your node is a direct child of a . Margins update automatically when you move or resize the node.
Distance between the node's bottom edge and its parent control, based on .
Margins are often controlled by one or multiple parent nodes, so you should not modify them manually if your node is a direct child of a . Margins update automatically when you move or resize the node.
Controls the direction on the horizontal axis in which the control should grow if its horizontal minimum size is changed to be greater than its current size, as the control always has to be at least the minimum size.
Controls the direction on the vertical axis in which the control should grow if its vertical minimum size is changed to be greater than its current size, as the control always has to be at least the minimum size.
The node's position, relative to its parent. It corresponds to the rectangle's top-left corner. The property is not affected by .
The node's global position, relative to the world (usually to the top-left corner of the window).
The size of the node's bounding rectangle, in pixels. nodes update this property automatically.
The minimum size of the node's bounding rectangle. If you set it to a value greater than (0, 0), the node's bounding rectangle will always have at least this size, even if its content is smaller. If it's set to (0, 0), the node sizes automatically to fit its content, be it a texture or child nodes.
The node's rotation around its pivot, in degrees. See to change the pivot's position.
The node's scale, relative to its . Change this property to scale the node around its . The Control's will also scale according to this value.
Note: This property is mainly intended to be used for animation purposes. Text inside the Control will look pixelated or blurry when the Control is scaled. To support multiple resolutions in your project, use an appropriate viewport stretch mode as described in the documentation instead of scaling Controls individually.
Note: If the Control node is a child of a node, the scale will be reset to Vector2(1, 1) when the scene is instanced. To set the Control's scale when it's instanced, wait for one frame using yield(get_tree(), "idle_frame") then set its property.
By default, the node's pivot is its top-left corner. When you change its or , it will rotate or scale around this pivot. Set this property to / 2 to pivot around the Control's center.
Enables whether rendering of based children should be clipped to this control's rectangle. If true, parts of a child which would be visibly outside of this control's rectangle will not be rendered.
Changes the tooltip text. The tooltip appears when the user's mouse cursor stays idle over this control for a few moments, provided that the property is not . You can change the time required for the tooltip to appear with gui/timers/tooltip_delay_sec option in Project Settings.
The tooltip popup will use either a default implementation, or a custom one that you can provide by overriding . The default tooltip includes a and whose theme properties can be customized using methods with the "TooltipPanel" and "TooltipLabel" respectively. For example:
var style_box = StyleBoxFlat.new()
style_box.set_bg_color(Color(1, 1, 0))
style_box.set_border_width_all(2)
# We assume here that the `theme` property has been assigned a custom Theme beforehand.
theme.set_stylebox("panel", "TooltipPanel", style_box)
theme.set_color("font_color", "TooltipLabel", Color(0, 1, 1))
Tells Godot which node it should give keyboard focus to if the user presses the left arrow on the keyboard or left on a gamepad by default. You can change the key by editing the ui_left input action. The node must be a . If this property is not set, Godot will give focus to the closest to the left of this one.
Tells Godot which node it should give keyboard focus to if the user presses the top arrow on the keyboard or top on a gamepad by default. You can change the key by editing the ui_top input action. The node must be a . If this property is not set, Godot will give focus to the closest to the bottom of this one.
Tells Godot which node it should give keyboard focus to if the user presses the right arrow on the keyboard or right on a gamepad by default. You can change the key by editing the ui_right input action. The node must be a . If this property is not set, Godot will give focus to the closest to the bottom of this one.
Tells Godot which node it should give keyboard focus to if the user presses the down arrow on the keyboard or down on a gamepad by default. You can change the key by editing the ui_down input action. The node must be a . If this property is not set, Godot will give focus to the closest to the bottom of this one.
Tells Godot which node it should give keyboard focus to if the user presses Tab on a keyboard by default. You can change the key by editing the ui_focus_next input action.
If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree.
Tells Godot which node it should give keyboard focus to if the user presses Shift+Tab on a keyboard by default. You can change the key by editing the ui_focus_prev input action.
If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree.
The focus access mode for the control (None, Click or All). Only one Control can be focused at the same time, and it will receive keyboard signals.
Controls whether the control will be able to receive mouse button input events through and how these events should be handled. Also controls whether the control can receive the mouse_entered, and mouse_exited signals. See the constants to learn what each does.
The default cursor shape for this control. Useful for Godot plugins and applications or games that use the system's mouse cursors.
Note: On Linux, shapes may vary depending on the cursor theme of the system.
Enables whether input should propagate when you close the control as modal.
If false, stops event handling at the viewport input event handling. The viewport first hides the modal and after marks the input as handled.
Tells the parent nodes how they should resize and place the node on the X axis. Use one of the constants to change the flags. See the constants to learn what each does.
Tells the parent nodes how they should resize and place the node on the Y axis. Use one of the constants to change the flags. See the constants to learn what each does.
If the node and at least one of its neighbours uses the size flag, the parent will let it take more or less space depending on this property. If this node has a stretch ratio of 2 and its neighbour a ratio of 1, this node will take two thirds of the available space.
Changing this property replaces the current resource this node and all its children use.
The name of a theme type variation used by this to look up its own theme items. When empty, the class name of the node is used (e.g. Button for the control), as well as the class names of all parent classes (in order of inheritance).
When set, this property gives the highest priority to the type of the specified name. This type can in turn extend another type, forming a dependency chain. See . If the theme item cannot be found using this type or its base types, lookup falls back on the class names.
Note: To look up 's own items use various get_* methods without specifying theme_type.
Note: Theme items are looked for in the tree order, from branch to root, where each node is checked for its property. The earliest match against any type/class name is returned. The project-level Theme and the default Theme are checked last.
Virtual method to be implemented by the user. Returns whether should not be called for children controls outside this control's rectangle. Input will be clipped to the Rect of this . Similar to , but doesn't affect visibility.
If not overridden, defaults to false.
Virtual method to be implemented by the user. Returns the minimum size for this control. Alternative to for controlling minimum size via code. The actual minimum size will be the max value of these two (in each axis separately).
If not overridden, defaults to Vector2.ZERO.
Note: This method will not be called when the script is attached to a node that already overrides its minimum size (e.g. , , etc.). It can only be used with most basic GUI nodes, like , , etc.
Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See .
Example: clicking a control.
func _gui_input(event):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT and event.pressed:
print("I've been clicked D:")
The event won't trigger if:
* clicking outside the control (see );
* control has set to ;
* control is obstructed by another on top of it, which doesn't have set to ;
* control's parent has set to or has accepted the event;
* it happens outside the parent's rectangle and the parent has either or enabled.
Note: Event position is relative to the control origin.
Virtual method to be implemented by the user. Returns a node that should be used as a tooltip instead of the default one. The for_text includes the contents of the property.
The returned node must be of type or Control-derived. It can have child nodes of any type. It is freed when the tooltip disappears, so make sure you always provide a new instance (if you want to use a pre-existing node from your scene tree, you can duplicate it and pass the duplicated instance). When null or a non-Control node is returned, the default tooltip will be used instead.
The returned node will be added as child to a , so you should only provide the contents of that panel. That can be themed using for the type "TooltipPanel" (see for an example).
Note: The tooltip is shrunk to minimal size. If you want to ensure it's fully visible, you might want to set its to some non-zero value.
Example of usage with a custom-constructed node:
func _make_custom_tooltip(for_text):
var label = Label.new()
label.text = for_text
return label
Example of usage with a custom scene instance:
func _make_custom_tooltip(for_text):
var tooltip = preload("res://SomeTooltipScene.tscn").instance()
tooltip.get_node("Label").text = for_text
return tooltip
Godot calls this method to test if data from a control's can be dropped at position. position is local to this control.
This method should only be used to test the data. Process the data in .
func can_drop_data(position, data):
# Check position if it is relevant to you
# Otherwise, just check data
return typeof(data) == TYPE_DICTIONARY and data.has("expected")
Godot calls this method to pass you the data from a control's result. Godot first calls to test if data is allowed to drop at position where position is local to this control.
func can_drop_data(position, data):
return typeof(data) == TYPE_DICTIONARY and data.has("color")
func drop_data(position, data):
color = data["color"]
Godot calls this method to get data that can be dragged and dropped onto controls that expect drop data. Returns null if there is no data to drag. Controls that want to receive drop data should implement and . position is local to this control. Drag may be forced with .
A preview that will follow the mouse that should represent the data can be set with . A good time to set the preview is in this method.
func get_drag_data(position):
var mydata = make_data()
set_drag_preview(make_preview(mydata))
return mydata
Virtual method to be implemented by the user. Returns whether the given point is inside this control.
If not overridden, default behavior is checking if the point is within control's Rect.
Note: If you want to check if a point is inside the control, you can use get_rect().has_point(point).
Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to or .
Returns the minimum size for this control. See .
Returns combined minimum size from and .
Sets the anchors to a preset from enum. This is the code equivalent to using the Layout menu in the 2D editor.
If keep_margins is true, control's position will also be updated.
Sets the margins to a preset from enum. This is the code equivalent to using the Layout menu in the 2D editor.
Use parameter resize_mode with constants from to better determine the resulting size of the . Constant size will be ignored if used with presets that change size, e.g. PRESET_LEFT_WIDE.
Use parameter margin to determine the gap between the and the edges.
Sets both anchor preset and margin preset. See and .
Sets the anchor identified by margin constant from enum to value anchor. A setter method for , , and .
If keep_margin is true, margins aren't updated after this operation.
If push_opposite_anchor is true and the opposite anchor overlaps this anchor, the opposite one will have its value overridden. For example, when setting left anchor to 1 and the right anchor has value of 0.5, the right anchor will also get value of 1. If push_opposite_anchor was false, the left anchor would get value 0.5.
Returns the anchor identified by margin constant from enum. A getter method for , , and .
Sets the margin identified by margin constant from enum to given offset. A setter method for , , and .
Works the same as , but instead of keep_margin argument and automatic update of margin, it allows to set the margin offset yourself (see ).
Sets and at the same time. Equivalent of changing .
Sets and at the same time.
Sets the to given position.
If keep_margins is true, control's anchors will be updated instead of margins.
Sets the size (see ).
If keep_margins is true, control's anchors will be updated instead of margins.
Sets the to given position.
If keep_margins is true, control's anchors will be updated instead of margins.
Sets the rotation (in radians).
Returns the anchor identified by margin constant from enum. A getter method for , , and .
Returns and . See also .
Returns and .
Returns the rotation (in radians).
Returns the width/height occupied in the parent control.
Returns the position and size of the control relative to the top-left corner of the parent Control. See and .
Returns the position and size of the control relative to the top-left corner of the screen. See and .
Displays a control as modal. Control must be a subwindow. Modal controls capture the input signals until closed or the area outside them is accessed. When a modal control loses focus, or the ESC key is pressed, they automatically hide. Modal controls are used extensively for popup dialogs and menus.
If exclusive is true, other controls will not receive input and clicking outside this control will not close it.
Returns true if this is the current focused control. See .
Steal the focus from another control and become the focused control (see ).
Note: Using this method together with makes it more reliable, especially when called inside .
Give up the focus. No other control will be able to receive keyboard input.
Finds the previous (above in the tree) that can receive the focus.
Finds the next (below in the tree) that can receive the focus.
Returns the control that has the keyboard focus or null if none.
Creates a local override for a theme icon with the specified name. Local overrides always take precedence when fetching theme items for the control.
Note: An override can be removed by assigning it a null value. This behavior is deprecated and will be removed in 4.0, use instead.
See also .
Creates a local override for a theme shader with the specified name. Local overrides always take precedence when fetching theme items for the control.
Note: An override can be removed by assigning it a null value. This behavior is deprecated and will be removed in 4.0, use instead.
Creates a local override for a theme with the specified name. Local overrides always take precedence when fetching theme items for the control.
Note: An override can be removed by assigning it a null value. This behavior is deprecated and will be removed in 4.0, use instead.
See also .
Example of modifying a property in a StyleBox by duplicating it:
# The snippet below assumes the child node MyButton has a StyleBoxFlat assigned.
# Resources are shared across instances, so we need to duplicate it
# to avoid modifying the appearance of all other buttons.
var new_stylebox_normal = $MyButton.get_stylebox("normal").duplicate()
new_stylebox_normal.border_width_top = 3
new_stylebox_normal.border_color = Color(0, 1, 0.5)
$MyButton.add_stylebox_override("normal", new_stylebox_normal)
# Remove the stylebox override.
$MyButton.add_stylebox_override("normal", null)
Creates a local override for a theme with the specified name. Local overrides always take precedence when fetching theme items for the control.
Note: An override can be removed by assigning it a null value. This behavior is deprecated and will be removed in 4.0, use instead.
See also .
Creates a local override for a theme with the specified name. Local overrides always take precedence when fetching theme items for the control.
See also , .
Example of overriding a label's color and resetting it later:
# Given the child Label node "MyLabel", override its font color with a custom value.
$MyLabel.add_color_override("font_color", Color(1, 0.5, 0))
# Reset the font color of the child label.
$MyLabel.add_color_override("font_color", get_color("font_color", "Label"))
Creates a local override for a theme constant with the specified name. Local overrides always take precedence when fetching theme items for the control.
See also , .
Removes a theme override for an icon with the given name.
Removes a theme override for a shader with the given name.
Removes a theme override for a with the given name.
Removes a theme override for a with the given name.
Removes a theme override for a with the given name.
Removes a theme override for a constant with the given name.
Returns an icon from the first matching in the tree if that has an icon item with the specified name and theme_type.
See for details.
Returns a from the first matching in the tree if that has a stylebox item with the specified name and theme_type.
See for details.
Returns a from the first matching in the tree if that has a font item with the specified name and theme_type.
See for details.
Returns a from the first matching in the tree if that has a color item with the specified name and theme_type. If theme_type is omitted the class name of the current control is used as the type, or if it is defined. If the type is a class name its parent classes are also checked, in order of inheritance.
For the current control its local overrides are considered first (see ), then its assigned . After the current control, each parent control and its assigned are considered; controls without a assigned are skipped. If no matching is found in the tree, a custom project (see ) and the default are used.
func _ready():
# Get the font color defined for the current Control's class, if it exists.
modulate = get_color("font_color")
# Get the font color defined for the Button class.
modulate = get_color("font_color", "Button")
Returns a constant from the first matching in the tree if that has a constant item with the specified name and theme_type.
See for details.
Returns true if there is a local override for a theme icon with the specified name in this node.
See .
Returns true if there is a local override for a theme shader with the specified name in this node.
See .
Returns true if there is a local override for a theme with the specified name in this node.
See .
Returns true if there is a local override for a theme with the specified name in this node.
See .
Returns true if there is a local override for a theme with the specified name in this node.
See .
Returns true if there is a local override for a theme constant with the specified name in this node.
See .
Returns true if there is a matching in the tree that has an icon item with the specified name and theme_type.
See for details.
Returns true if there is a matching in the tree that has a stylebox item with the specified name and theme_type.
See for details.
Returns true if there is a matching in the tree that has a font item with the specified name and theme_type.
See for details.
Returns true if there is a matching in the tree that has a color item with the specified name and theme_type.
See for details.
Returns true if there is a matching in the tree that has a constant item with the specified name and theme_type.
See for details.
Returns the default font from the first matching in the tree if that has a valid value.
See for details.
Returns the parent control node.
Returns the tooltip, which will appear when the cursor is resting over this control. See .
If the parameter is null, then the default value is new Vector2(0, 0)
Returns the mouse cursor shape the control displays on mouse hover. See .
If the parameter is null, then the default value is new Vector2(0, 0)
Sets the anchor identified by margin constant from enum to at neighbor node path. A setter method for , , and .
Returns the focus neighbour identified by margin constant from enum. A getter method for , , and .
Forces drag and bypasses and by passing data and preview. Drag will start even if the mouse is neither over nor pressed on this control.
The methods and must be implemented on controls that want to receive drop data.
Creates an that attempts to click the control. If the event is received, the control acquires focus.
func _process(delta):
grab_click_focus() #when clicking another Control node, this node will be clicked instead
Forwards the handling of this control's drag and drop to target control.
Forwarding can be implemented in the target control similar to the methods , , and but with two differences:
1. The function name must be suffixed with _fw
2. The function must take an extra argument that is the control doing the forwarding
# ThisControl.gd
extends Control
func _ready():
set_drag_forwarding(target_control)
# TargetControl.gd
extends Control
func can_drop_data_fw(position, data, from_control):
return true
func drop_data_fw(position, data, from_control):
my_handle_data(data)
func get_drag_data_fw(position, from_control):
set_drag_preview(my_preview)
return my_data()
Shows the given control at the mouse pointer. A good time to call this method is in . The control must not be in the scene tree. You should not free the control, and you should not keep a reference to the control beyond the duration of the drag. It will be deleted automatically after the drag has ended.
export (Color, RGBA) var color = Color(1, 0, 0, 1)
func get_drag_data(position):
# Use a control that is not in the tree
var cpb = ColorPickerButton.new()
cpb.color = color
cpb.rect_size = Vector2(50, 50)
set_drag_preview(cpb)
return color
Returns true if a drag operation is successful. Alternative to .
Best used with .
Moves the mouse cursor to to_position, relative to of this .
Invalidates the size cache in this node and in parent nodes up to toplevel. Intended to be used with when the return value is changed. Setting directly calls this method automatically.
Convex polygon shape resource, which can be added to a or area.
The list of 3D points forming the convex polygon shape.
Convex polygon shape for 2D physics. A convex polygon, whatever its shape, is internally decomposed into as many convex polygons as needed to ensure all collision checks against it are always done on convex polygons (which are faster to check).
The main difference between a and a is that a concave polygon assumes it is concave and uses a more complex method of collision detection, and a convex one forces itself to be convex in order to speed up collision detection.
The polygon's list of vertices. Can be in either clockwise or counterclockwise order. Only set this property with convex hull points, use to generate a convex hull shape from concave shape points.
Based on the set of points provided, this creates and assigns the property using the convex hull algorithm. Removing all unneeded points. See for details.
The Crypto class allows you to access some more advanced cryptographic functionalities in Godot.
For now, this includes generating cryptographically secure random bytes, RSA keys and self-signed X509 certificates generation, asymmetric key encryption/decryption, and signing/verification.
extends Node
var crypto = Crypto.new()
var key = CryptoKey.new()
var cert = X509Certificate.new()
func _ready():
# Generate new RSA key.
key = crypto.generate_rsa(4096)
# Generate new self-signed certificate with the given key.
cert = crypto.generate_self_signed_certificate(key, "CN=mydomain.com,O=My Game Company,C=IT")
# Save key and certificate in the user folder.
key.save("user://generated.key")
cert.save("user://generated.crt")
# Encryption
var data = "Some data"
var encrypted = crypto.encrypt(key, data.to_utf8())
# Decryption
var decrypted = crypto.decrypt(key, encrypted)
# Signing
var signature = crypto.sign(HashingContext.HASH_SHA256, data.sha256_buffer(), key)
# Verifying
var verified = crypto.verify(HashingContext.HASH_SHA256, data.sha256_buffer(), signature, key)
# Checks
assert(verified)
assert(data.to_utf8() == decrypted)
Note: Not available in HTML5 exports.
Generates a of cryptographically secure random bytes with given size.
Generates an RSA that can be used for creating self-signed certificates and passed to .
Generates a self-signed from the given and issuer_name. The certificate validity will be defined by not_before and not_after (first valid date and last valid date). The issuer_name must contain at least "CN=" (common name, i.e. the domain name), "O=" (organization, i.e. your company name), "C=" (country, i.e. 2 lettered ISO-3166 code of the country the organization is based in).
A small example to generate an RSA key and a X509 self-signed certificate.
var crypto = Crypto.new()
# Generate 4096 bits RSA key.
var key = crypto.generate_rsa(4096)
# Generate self-signed certificate using the given key.
var cert = crypto.generate_self_signed_certificate(key, "CN=example.com,O=A Game Company,C=IT")
Sign a given hash of type hash_type with the provided private key.
Verify that a given signature for hash of type hash_type against the provided public key.
Encrypt the given plaintext with the provided public key.
Note: The maximum size of accepted plaintext is limited by the key size.
Decrypt the given ciphertext with the provided private key.
Note: The maximum size of accepted ciphertext is limited by the key size.
Generates an HMAC digest of msg using key. The hash_type parameter is the hashing algorithm that is used for the inner and outer hashes.
Currently, only and are supported.
Compares two s for equality without leaking timing information in order to prevent timing attacks.
See this blog post for more information.
The CryptoKey class represents a cryptographic key. Keys can be loaded and saved like any other .
They can be used to generate a self-signed via and as private key in along with the appropriate certificate.
Saves a key to the given path. If public_only is true, only the public key will be saved.
Note: path should be a "*.pub" file if public_only is true, a "*.key" file otherwise.
Loads a key from path. If public_only is true, only the public key will be loaded.
Note: path should be a "*.pub" file if public_only is true, a "*.key" file otherwise.
Return true if this CryptoKey only has the public part, and not the private one.
Returns a string containing the key in PEM format. If public_only is true, only the public key will be included.
Loads a key from the given string. If public_only is true, only the public key will be loaded.
A 6-sided 3D texture typically used for faking reflections. It can be used to make an object look as if it's reflecting its surroundings. This usually delivers much better performance than other reflection methods.
Generate mipmaps, to enable smooth zooming out of the texture.
Repeat (instead of clamp to edge).
Turn on magnifying filter, to enable smooth zooming in of the texture.
Default flags. Generate mipmaps, repeat, and filter are enabled.
Identifier for the left face of the .
Identifier for the right face of the .
Identifier for the bottom face of the .
Identifier for the top face of the .
Identifier for the front face of the .
Identifier for the back face of the .
Store the without any compression.
Store the with strong compression that reduces image quality.
Store the with moderate compression that doesn't reduce image quality.
The render flags for the . See the constants for details.
The 's storage mode. See constants.
The lossy storage quality of the if the storage mode is set to .
Returns the 's width.
Returns the 's height.
Sets an for a side of the using one of the constants.
Returns an for a side of the using one of the constants.
Generate an axis-aligned cuboid .
The cube's UV layout is arranged in a 3×2 layout that allows texturing each face individually. To apply the same texture on all faces, change the material's UV property to Vector3(3, 2, 1).
Note: When using a large textured (e.g. as a floor), you may stumble upon UV jittering issues depending on the camera angle. To solve this, increase , and until you no longer notice UV jittering.
Size of the cuboid mesh.
Number of extra edge loops inserted along the X axis.
Number of extra edge loops inserted along the Y axis.
Number of extra edge loops inserted along the Z axis.
Provides common functionality to nodes that can be culled by the system.
Static and Dynamic objects are the most efficiently managed objects in the system, but there are some caveats. They are expected to be present initially when s are converted using the rooms_convert function, and their lifetime should be the same as the game level (i.e. present until you call rooms_clear on the . Although you shouldn't create / delete these objects during gameplay, you can manage their visibility with the standard hide and show commands.
Roaming objects on the other hand, require extra processing to keep track of which they are within. This enables them to be culled effectively, wherever they are.
Global objects are not culled by the portal system, and use view frustum culling only.
Objects that are not Static or Dynamic can be freely created and deleted during the lifetime of the game level.
Use for instances within s that will not move - e.g. walls, floors.
Note: If you attempt to delete a PORTAL_MODE_STATIC instance while the room graph is loaded (converted), it will unload the room graph and deactivate portal culling. This is because the room graph data has been invalidated. You will need to reconvert the rooms using the to activate the system again.
Use for instances within rooms that will move but not change room - e.g. moving platforms.
Note: If you attempt to delete a PORTAL_MODE_DYNAMIC instance while the room graph is loaded (converted), it will unload the room graph and deactivate portal culling. This is because the room graph data has been invalidated. You will need to reconvert the rooms using the to activate the system again.
Use for instances that will move between s - e.g. players.
Use for instances that will be frustum culled only - e.g. first person weapon, debug.
Use for instances that will not be shown at all - e.g. manual room bounds (specified by prefix 'Bound_').
When using s and s, this specifies how the is processed in the system.
When a manual bound has not been explicitly specified for a , the convex hull bound will be estimated from the geometry of the objects within the room. This setting determines whether the geometry of an object is included in this estimate of the room bound.
Note: This setting is only relevant when the object is set to PORTAL_MODE_STATIC or PORTAL_MODE_DYNAMIC, and for s.
This allows fine control over the mesh merging feature in the .
Setting this option to false can be used to prevent an instance being merged.
When set to 0, s will be autoplaced in the with the highest priority.
When set to a value other than 0, the system will attempt to autoplace in a with the autoplace_priority, if it is present.
This can be used to control autoplacement of building exteriors in an outer .
A curve that can be saved and re-used for other objects. By default, it ranges between 0 and 1 on the Y axis and positions points relative to the 0.5 Y position.
See also which is designed for color interpolation. See also and .
The tangent on this side of the point is user-defined.
The curve calculates the tangent on this side of the point as the slope halfway towards the adjacent point.
The total number of available tangent modes.
The minimum value the curve can reach.
The maximum value the curve can reach.
The number of points to include in the baked (i.e. cached) curve data.
Returns the number of points describing the curve.
Adds a point to the curve. For each side, if the *_mode is , the *_tangent angle (in degrees) uses the slope of the curve halfway to the adjacent point. Allows custom assignments to the *_tangent angle if *_mode is set to .
Removes the point at index from the curve.
Removes all points from the curve.
Returns the curve coordinates for the point at index.
Assigns the vertical position y to the point at index.
Sets the offset from 0.5.
Returns the Y value for the point that would exist at the X position offset along the curve.
Returns the Y value for the point that would exist at the X position offset along the curve using the baked cache. Bakes the curve's points if not already baked.
Returns the left tangent angle (in degrees) for the point at index.
Returns the right tangent angle (in degrees) for the point at index.
Returns the left for the point at index.
Returns the right for the point at index.
Sets the left tangent angle for the point at index to tangent.
Sets the right tangent angle for the point at index to tangent.
Sets the left for the point at index to mode.
Sets the right for the point at index to mode.
Removes points that are closer than CMP_EPSILON (0.00001) units to their neighbor on the curve.
Recomputes the baked cache of points for the curve.
This class describes a Bézier curve in 2D space. It is mainly used to give a shape to a , but can be manually sampled for other purposes.
It keeps a cache of precalculated points along the curve, to speed up further calculations.
The distance in pixels between two adjacent cached points. Changing it forces the cache to be recomputed the next time the or function is called. The smaller the distance, the more points in the cache and the more memory it will consume, so use with care.
Returns the number of points describing the curve.
Adds a point with the specified position relative to the curve's own position, with control points in and out. Appends the new point at the end of the point list.
If index is given, the new point is inserted before the existing point identified by index index. Every existing point starting from index is shifted further down the list of points. The index must be greater than or equal to 0 and must not exceed the number of existing points in the line. See .
If the parameter is null, then the default value is new Vector2(0, 0)
If the parameter is null, then the default value is new Vector2(0, 0)
Sets the position for the vertex idx. If the index is out of bounds, the function sends an error to the console.
Returns the position of the vertex idx. If the index is out of bounds, the function sends an error to the console, and returns (0, 0).
Sets the position of the control point leading to the vertex idx. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex.
Returns the position of the control point leading to the vertex idx. The returned position is relative to the vertex idx. If the index is out of bounds, the function sends an error to the console, and returns (0, 0).
Sets the position of the control point leading out of the vertex idx. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex.
Returns the position of the control point leading out of the vertex idx. The returned position is relative to the vertex idx. If the index is out of bounds, the function sends an error to the console, and returns (0, 0).
Deletes the point idx from the curve. Sends an error to the console if idx is out of bounds.
Removes all points from the curve.
Returns the position between the vertex idx and the vertex idx + 1, where t controls if the point is the first vertex (t = 0.0), the last vertex (t = 1.0), or in between. Values of t outside the range (0.0 >= t <=1) give strange, but predictable results.
If idx is out of bounds it is truncated to the first or last vertex, and t is ignored. If the curve has no points, the function sends an error to the console, and returns (0, 0).
Returns the position at the vertex fofs. It calls using the integer part of fofs as idx, and its fractional part as t.
Returns the total length of the curve, based on the cached points. Given enough density (see ), it should be approximate enough.
Returns a point within the curve at position offset, where offset is measured as a pixel distance along the curve.
To do that, it finds the two cached points where the offset lies between, then interpolates the values. This interpolation is cubic if cubic is set to true, or linear if set to false.
Cubic interpolation tends to follow the curves better, but linear is faster (and often, precise enough).
Returns the cache of points as a .
Returns the closest baked point (in curve's local space) to to_point.
to_point must be in this curve's local space.
Returns the closest offset to to_point. This offset is meant to be used in .
to_point must be in this curve's local space.
Returns a list of points along the curve, with a curvature controlled point density. That is, the curvier parts will have more points than the straighter parts.
This approximation makes straight segments between each point, then subdivides those segments until the resulting shape is similar enough.
max_stages controls how many subdivisions a curve segment may face before it is considered approximate enough. Each subdivision splits the segment in half, so the default 5 stages may mean up to 32 subdivisions per curve segment. Increase with care!
tolerance_degrees controls how many degrees the midpoint of a segment may deviate from the real curve, before the segment has to be subdivided.
This class describes a Bézier curve in 3D space. It is mainly used to give a shape to a , but can be manually sampled for other purposes.
It keeps a cache of precalculated points along the curve, to speed up further calculations.
The distance in meters between two adjacent cached points. Changing it forces the cache to be recomputed the next time the or function is called. The smaller the distance, the more points in the cache and the more memory it will consume, so use with care.
If true, the curve will bake up vectors used for orientation. This is used when is set to . Changing it forces the cache to be recomputed.
Returns the number of points describing the curve.
Adds a point with the specified position relative to the curve's own position, with control points in and out. Appends the new point at the end of the point list.
If index is given, the new point is inserted before the existing point identified by index index. Every existing point starting from index is shifted further down the list of points. The index must be greater than or equal to 0 and must not exceed the number of existing points in the line. See .
If the parameter is null, then the default value is new Vector3(0, 0, 0)
If the parameter is null, then the default value is new Vector3(0, 0, 0)
Sets the position for the vertex idx. If the index is out of bounds, the function sends an error to the console.
Returns the position of the vertex idx. If the index is out of bounds, the function sends an error to the console, and returns (0, 0, 0).
Sets the tilt angle in radians for the point idx. If the index is out of bounds, the function sends an error to the console.
The tilt controls the rotation along the look-at axis an object traveling the path would have. In the case of a curve controlling a , this tilt is an offset over the natural tilt the calculates.
Returns the tilt angle in radians for the point idx. If the index is out of bounds, the function sends an error to the console, and returns 0.
Sets the position of the control point leading to the vertex idx. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex.
Returns the position of the control point leading to the vertex idx. The returned position is relative to the vertex idx. If the index is out of bounds, the function sends an error to the console, and returns (0, 0, 0).
Sets the position of the control point leading out of the vertex idx. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex.
Returns the position of the control point leading out of the vertex idx. The returned position is relative to the vertex idx. If the index is out of bounds, the function sends an error to the console, and returns (0, 0, 0).
Deletes the point idx from the curve. Sends an error to the console if idx is out of bounds.
Removes all points from the curve.
Returns the position between the vertex idx and the vertex idx + 1, where t controls if the point is the first vertex (t = 0.0), the last vertex (t = 1.0), or in between. Values of t outside the range (0.0 >= t <=1) give strange, but predictable results.
If idx is out of bounds it is truncated to the first or last vertex, and t is ignored. If the curve has no points, the function sends an error to the console, and returns (0, 0, 0).
Returns the position at the vertex fofs. It calls using the integer part of fofs as idx, and its fractional part as t.
Returns the total length of the curve, based on the cached points. Given enough density (see ), it should be approximate enough.
Returns a point within the curve at position offset, where offset is measured as a distance in 3D units along the curve.
To do that, it finds the two cached points where the offset lies between, then interpolates the values. This interpolation is cubic if cubic is set to true, or linear if set to false.
Cubic interpolation tends to follow the curves better, but linear is faster (and often, precise enough).
Returns an up vector within the curve at position offset, where offset is measured as a distance in 3D units along the curve.
To do that, it finds the two cached up vectors where the offset lies between, then interpolates the values. If apply_tilt is true, an interpolated tilt is applied to the interpolated up vector.
If the curve has no up vectors, the function sends an error to the console, and returns (0, 1, 0).
Returns the cache of points as a .
Returns the cache of tilts as a .
Returns the cache of up vectors as a .
If is false, the cache will be empty.
Returns the closest baked point (in curve's local space) to to_point.
to_point must be in this curve's local space.
Returns the closest offset to to_point. This offset is meant to be used in or .
to_point must be in this curve's local space.
Returns a list of points along the curve, with a curvature controlled point density. That is, the curvier parts will have more points than the straighter parts.
This approximation makes straight segments between each point, then subdivides those segments until the resulting shape is similar enough.
max_stages controls how many subdivisions a curve segment may face before it is considered approximate enough. Each subdivision splits the segment in half, so the default 5 stages may mean up to 32 subdivisions per curve segment. Increase with care!
tolerance_degrees controls how many degrees the midpoint of a segment may deviate from the real curve, before the segment has to be subdivided.
Renders a given provided to it. Simplifies the task of drawing curves and/or saving them as image files.
The width of the texture (in pixels). Higher values make it possible to represent high-frequency data better (such as sudden direction changes), at the cost of increased generation time and memory usage.
The that is rendered onto the texture.
Class representing a cylindrical . This class can be used to create cones by setting either the or properties to 0.0.
Top radius of the cylinder. If set to 0.0, the top faces will not be generated, resulting in a conic shape.
Bottom radius of the cylinder. If set to 0.0, the bottom faces will not be generated, resulting in a conic shape.
Full height of the cylinder.
Number of radial segments on the cylinder. Higher values result in a more detailed cylinder/cone at the cost of performance.
Number of edge rings along the height of the cylinder. Changing does not have any visual impact unless a shader or procedural mesh tool is used to alter the vertex data. Higher values result in more subdivisions, which can be used to create smoother-looking effects with shaders or procedural mesh tools (at the cost of performance). When not altering the vertex data using a shader or procedural mesh tool, should be kept to its default value.
Cylinder shape for collisions.
The cylinder's height.
The cylinder's radius.
This class is used to store the state of a DTLS server. Upon it converts connected to accepting them via as DTLS clients. Under the hood, this class is used to store the DTLS state and cookies of the server. The reason of why the state and cookies are needed is outside of the scope of this documentation.
Below a small example of how to use it:
# server.gd
extends Node
var dtls := DTLSServer.new()
var server := UDPServer.new()
var peers = []
func _ready():
server.listen(4242)
var key = load("key.key") # Your private key.
var cert = load("cert.crt") # Your X509 certificate.
dtls.setup(key, cert)
func _process(delta):
while server.is_connection_available():
var peer : PacketPeerUDP = server.take_connection()
var dtls_peer : PacketPeerDTLS = dtls.take_connection(peer)
if dtls_peer.get_status() != PacketPeerDTLS.STATUS_HANDSHAKING:
continue # It is normal that 50% of the connections fails due to cookie exchange.
print("Peer connected!")
peers.append(dtls_peer)
for p in peers:
p.poll() # Must poll to update the state.
if p.get_status() == PacketPeerDTLS.STATUS_CONNECTED:
while p.get_available_packet_count() > 0:
print("Received message from client: %s" % p.get_packet().get_string_from_utf8())
p.put_packet("Hello DTLS client".to_utf8())
# client.gd
extends Node
var dtls := PacketPeerDTLS.new()
var udp := PacketPeerUDP.new()
var connected = false
func _ready():
udp.connect_to_host("127.0.0.1", 4242)
dtls.connect_to_peer(udp, false) # Use true in production for certificate validation!
func _process(delta):
dtls.poll()
if dtls.get_status() == PacketPeerDTLS.STATUS_CONNECTED:
if !connected:
# Try to contact server
dtls.put_packet("The answer is... 42!".to_utf8())
while dtls.get_available_packet_count() > 0:
print("Connected: %s" % dtls.get_packet().get_string_from_utf8())
connected = true
Setup the DTLS server to use the given private_key and provide the given certificate to clients. You can pass the optional chain parameter to provide additional CA chain information along with the certificate.
Try to initiate the DTLS handshake with the given udp_peer which must be already connected (see ).
Note: You must check that the state of the return PacketPeerUDP is , as it is normal that 50% of the new connections will be invalid due to cookie exchange.
Damped spring constraint for 2D physics. This resembles a spring joint that always wants to go back to a given length.
The spring joint's maximum length. The two attached bodies cannot stretch it past this value.
When the bodies attached to the spring joint move they stretch or squash it. The joint always tries to resize towards this length.
The higher the value, the less the bodies attached to the joint will deform it. The joint applies an opposing force to the bodies, the product of the stiffness multiplied by the size difference from its resting length.
The spring joint's damping ratio. A value between 0 and 1. When the two bodies move into different directions the system tries to align them to the spring axis again. A high damping value forces the attached bodies to align faster.
A directional light is a type of node that models an infinite number of parallel rays covering the entire scene. It is used for lights with strong intensity that are located far away from the scene to model sunlight or moonlight. The worldspace location of the DirectionalLight transform (origin) is ignored. Only the basis is used to determine light direction.
Renders the entire scene's shadow map from an orthogonal point of view. This is the fastest directional shadow mode. May result in blurrier shadows on close objects.
Splits the view frustum in 2 areas, each with its own shadow map. This shadow mode is a compromise between and in terms of performance.
Splits the view frustum in 4 areas, each with its own shadow map. This is the slowest directional shadow mode.
Keeps the shadow stable when the camera moves, at the cost of lower effective shadow resolution.
Tries to achieve maximum shadow resolution. May result in saw effect on shadow edges. This mode typically works best in games where the camera will often move at high speeds, such as most racing games.
The light's shadow rendering algorithm. See .
The distance from camera to shadow split 1. Relative to . Only used when is or .
The distance from shadow split 1 to split 2. Relative to . Only used when is or .
The distance from shadow split 2 to split 3. Relative to . Only used when is .
If true, shadow detail is sacrificed in exchange for smoother transitions between splits. Enabling shadow blend splitting also has a moderate performance cost. This is ignored when is .
Can be used to fix special cases of self shadowing when objects are perpendicular to the light.
Amount of extra bias for shadow splits that are far away. If self-shadowing occurs only on the splits far away, increasing this value can fix them. This is ignored when is .
Optimizes shadow rendering for detail versus movement. See .
The maximum distance for shadow splits. Increasing this value will make directional shadows visible from further away, at the cost of lower overall shadow detail and performance (since more objects need to be included in the directional shadow rendering).
DynamicFont renders vector font files dynamically at runtime instead of using a prerendered texture atlas like . This trades the faster loading time of s for the ability to change font parameters like size and spacing during runtime. is used for referencing the font file paths. DynamicFont also supports defining one or more fallback fonts, which will be used when displaying a character not supported by the main font.
DynamicFont uses the FreeType library for rasterization. Supported formats are TrueType (.ttf), OpenType (.otf), Web Open Font Format 1 (.woff), and Web Open Font Format 2 (.woff2).
var dynamic_font = DynamicFont.new()
dynamic_font.font_data = load("res://BarlowCondensed-Bold.ttf")
dynamic_font.size = 64
$"Label".set("custom_fonts/font", dynamic_font)
Note: DynamicFont doesn't support features such as kerning, right-to-left typesetting, ligatures, text shaping, variable fonts and optional font features yet. If you wish to "bake" an optional font feature into a TTF font file, you can use FontForge to do so. In FontForge, use File > Generate Fonts, click Options, choose the desired features then generate the font.
Spacing at the top.
Spacing at the bottom.
Spacing for each character.
Spacing for the space character.
The font size in pixels.
The font outline's thickness in pixels (not relative to the font size).
The font outline's color.
Note: It's recommended to leave this at the default value so that you can adjust it in individual controls. For example, if the outline is made black here, it won't be possible to change its color using a Label's font outline modulate theme item.
If true, mipmapping is used. This improves the font's appearance when downscaling it if font oversampling is disabled or ineffective.
If true, filtering is used. This makes the font blurry instead of pixelated when scaling it if font oversampling is disabled or ineffective. It's recommended to enable this when using the font in a control whose size changes over time, unless a pixel art aesthetic is desired.
Extra spacing at the top in pixels.
Extra spacing at the bottom in pixels.
Extra spacing for each character in pixels.
This can be a negative number to make the distance between characters smaller.
Extra spacing for the space character (in addition to ) in pixels.
This can be a negative number to make the distance between words smaller.
The font data.
Returns a string containing all the characters available in the main and all the fallback fonts.
If a given character is included in more than one font, it appears only once in the returned string.
Sets the spacing for type (see ) to value in pixels (not relative to the font size).
Returns the spacing for the given type (see ).
Adds a fallback font.
Sets the fallback font at index idx.
Returns the fallback font at index idx.
Removes the fallback font at index idx.
Returns the number of fallback fonts.
Used with to describe the location of a vector font file for dynamic rendering at runtime.
Disables font hinting (smoother but less crisp).
Use the light font hinting mode.
Use the default font hinting mode (crisper but less smooth).
If true, the font is rendered with anti-aliasing. This property applies both to the main font and its outline (if it has one).
The font hinting mode used by FreeType. See for options.
If set to a value greater than 0.0, it will override default font oversampling, ignoring value and viewport stretch mode.
The path to the vector font file.
Utility class which holds a reference to the internal identifier of an instance, as given by . This ID can then be used to retrieve the object instance with @GDScript.instance_from_id.
This class is used internally by the editor inspector and script debugger, but can also be used in plugins to pass and display objects as their IDs.
The identifier stored in this instance. The object instance can be retrieved with @GDScript.instance_from_id.
Resource for environment nodes (like ) that define multiple environment operations (such as background or , ambient light, fog, depth-of-field...). These parameters affect the final render of the scene. The order of these operations is:
- Depth of Field Blur
- Glow
- Tonemap (Auto Exposure)
- Adjustments
If the target is set to "2D Without Sampling", all post-processing effects will be unavailable. With "3D Without Effects", the following options will be unavailable:
- Ssao
- Ss Reflections
This can be configured for the root Viewport with , or for specific Viewports via the property.
Note that has a mobile platform override to use "3D Without Effects" by default. It improves the performance on mobile devices, but at the same time affects the screen display on mobile devices.
No blur for the screen-space ambient occlusion effect (fastest).
1×1 blur for the screen-space ambient occlusion effect.
2×2 blur for the screen-space ambient occlusion effect.
3×3 blur for the screen-space ambient occlusion effect (slowest).
Linear tonemapper operator. Reads the linear data and passes it on unmodified. This can cause bright lighting to look blown out, with noticeable clipping in the output colors.
Reinhardt tonemapper operator. Performs a variation on rendered pixels' colors by this formula: color = color / (1 + color). This avoids clipping bright highlights, but the resulting image can look a bit dull.
Filmic tonemapper operator. This avoids clipping bright highlights, with a resulting image that usually looks more vivid than .
Use the legacy Godot version of the Academy Color Encoding System tonemapper. Unlike , this version of ACES does not handle bright lighting in a physically accurate way. ACES typically has a more contrasted output compared to and .
Note: This tonemapping operator will be removed in Godot 4.0 in favor of the more accurate .
Use the Academy Color Encoding System tonemapper. ACES is slightly more expensive than other options, but it handles bright lighting in a more realistic fashion by desaturating it as it becomes brighter. ACES typically has a more contrasted output compared to and .
Additive glow blending mode. Mostly used for particles, glows (bloom), lens flare, bright sources.
Screen glow blending mode. Increases brightness, used frequently with bloom.
Soft light glow blending mode. Modifies contrast, exposes shadows and highlights (vivid bloom).
Replace glow blending mode. Replaces all pixels' color by the glow value. This can be used to simulate a full-screen blur effect by tweaking the glow parameters to match the original image's brightness.
Keeps on screen every pixel drawn in the background. Only select this mode if you really need to keep the old data. On modern GPUs it will generally not be faster than clearing the background, and can be significantly slower, particularly on mobile.
It can only be safely used in fully-interior scenes (no visible sky or sky reflections). If enabled in a scene where the background is visible, "ghost trail" artifacts will be visible when moving the camera.
Clears the background using the clear color defined in .
Clears the background using a custom clear color.
Displays a user-defined sky in the background.
Clears the background using a custom clear color and allows defining a sky for shading and reflection. This mode is slightly faster than and should be preferred in scenes where reflections can be visible, but the sky itself never is (e.g. top-down camera).
Displays a in the background.
Displays a camera feed in the background.
Represents the size of the enum.
Low quality for the screen-space ambient occlusion effect (fastest).
Medium quality for the screen-space ambient occlusion effect.
High quality for the screen-space ambient occlusion effect (slowest).
Low depth-of-field blur quality (fastest).
Medium depth-of-field blur quality.
High depth-of-field blur quality (slowest).
The background mode. See for possible values.
The resource defined as background.
The resource's custom field of view.
The resource's rotation expressed as a .
The resource's rotation expressed as Euler angles in radians.
The resource's rotation expressed as Euler angles in degrees.
The displayed for clear areas of the scene. Only effective when using the or background modes).
The power of the light emitted by the background.
The maximum layer ID to display. Only effective when using the background mode.
The ID of the camera feed to show in the background.
The ambient light's .
The ambient light's energy. The higher the value, the stronger the light.
Defines the amount of light that the sky brings on the scene. A value of 0.0 means that the sky's light emission has no effect on the scene illumination, thus all ambient illumination is provided by the ambient light. On the contrary, a value of 1.0 means that all the light that affects the scene is provided by the sky, thus the ambient light parameter has no effect on the scene.
Note: is internally clamped between 0.0 and 1.0 (inclusive).
If true, fog effects are enabled. and/or must be set to true to actually display fog.
The fog's .
The depth fog's when looking towards the sun.
The intensity of the depth fog color transition when looking towards the sun. The sun's direction is determined automatically using the DirectionalLight node in the scene.
If true, the depth fog effect is enabled. When enabled, fog will appear in the distance (relative to the camera).
The fog's depth starting distance from the camera.
The fog's depth end distance from the camera. If this value is set to 0, it will be equal to the current camera's value.
The fog depth's intensity curve. A number of presets are available in the Inspector by right-clicking the curve.
Enables fog's light transmission effect. If true, light will be more visible in the fog to simulate light scattering as in real life.
The intensity of the fog light transmittance effect. Amount of light that the fog transmits.
If true, the height fog effect is enabled. When enabled, fog will appear in a defined height range, regardless of the distance from the camera. This can be used to simulate "deep water" effects with a lower performance cost compared to a dedicated shader.
The Y coordinate where the height fog will be the least intense. If this value is greater than , fog will be displayed from top to bottom. Otherwise, it will be displayed from bottom to top.
The Y coordinate where the height fog will be the most intense. If this value is greater than , fog will be displayed from bottom to top. Otherwise, it will be displayed from top to bottom.
The height fog's intensity. A number of presets are available in the Inspector by right-clicking the curve.
The tonemapping mode to use. Tonemapping is the process that "converts" HDR values to be suitable for rendering on a SDR display. (Godot doesn't support rendering on HDR displays yet.)
The default exposure used for tonemapping.
The white reference value for tonemapping. Only effective if the isn't set to .
If true, enables the tonemapping auto exposure mode of the scene renderer. If true, the renderer will automatically determine the exposure setting to adapt to the scene's illumination and the observed light.
The scale of the auto exposure effect. Affects the intensity of auto exposure.
The minimum luminance value for the auto exposure.
The maximum luminance value for the auto exposure.
The speed of the auto exposure effect. Affects the time needed for the camera to perform auto exposure.
If true, screen-space reflections are enabled. Screen-space reflections are more accurate than reflections from s or s, but are slower and can't reflect surfaces occluded by others.
The maximum number of steps for screen-space reflections. Higher values are slower.
The fade-in distance for screen-space reflections. Affects the area from the reflected material to the screen-space reflection).
The fade-out distance for screen-space reflections. Affects the area from the screen-space reflection to the "global" reflection.
The depth tolerance for screen-space reflections.
If true, screen-space reflections will take the material roughness into account.
If true, the screen-space ambient occlusion effect is enabled. This darkens objects' corners and cavities to simulate ambient light not reaching the entire object as in real life. This works well for small, dynamic objects, but baked lighting or ambient occlusion textures will do a better job at displaying ambient occlusion on large static objects. This is a costly effect and should be disabled first when running into performance issues.
The primary screen-space ambient occlusion radius.
The primary screen-space ambient occlusion intensity. See also .
The secondary screen-space ambient occlusion radius. If set to a value higher than 0, enables the secondary screen-space ambient occlusion effect which can be used to improve the effect's appearance (at the cost of performance).
The secondary screen-space ambient occlusion intensity. See also .
The screen-space ambient occlusion bias. This should be kept high enough to prevent "smooth" curves from being affected by ambient occlusion.
The screen-space ambient occlusion intensity in direct light. In real life, ambient occlusion only applies to indirect light, which means its effects can't be seen in direct light. Values higher than 0 will make the SSAO effect visible in direct light.
The screen-space ambient occlusion intensity on materials that have an AO texture defined. Values higher than 0 will make the SSAO effect visible in areas darkened by AO textures.
The screen-space ambient occlusion color.
The screen-space ambient occlusion quality. Higher qualities will make better use of small objects for ambient occlusion, but are slower.
The screen-space ambient occlusion blur quality. See for possible values.
The screen-space ambient occlusion edge sharpness.
If true, enables the depth-of-field far blur effect.
The distance from the camera where the far blur effect affects the rendering.
The length of the transition between the no-blur area and far blur.
The amount of far blur for the depth-of-field effect.
The depth-of-field far blur's quality. Higher values can mitigate the visible banding effect seen at higher strengths, but are much slower.
If true, enables the depth-of-field near blur effect.
Distance from the camera where the near blur effect affects the rendering.
The length of the transition between the near blur and no-blur area.
The amount of near blur for the depth-of-field effect.
The depth-of-field near blur's quality. Higher values can mitigate the visible banding effect seen at higher strengths, but are much slower.
If true, the glow effect is enabled.
Note: Only effective if is 3D (not 3D Without Effects). On mobile, defaults to 3D Without Effects by default, so its .mobile override needs to be changed to 3D.
Note: When using GLES3 on mobile, HDR rendering is disabled by default for performance reasons. This means glow will only be visible if is decreased below 1.0 or if is increased above 0.0. Also consider increasing to 1.5. If you want glow to behave on mobile like it does on desktop (at a performance cost), enable 's .mobile override.
If true, the 1st level of glow is enabled. This is the most "local" level (least blurry).
If true, the 2th level of glow is enabled.
If true, the 3th level of glow is enabled.
If true, the 4th level of glow is enabled.
If true, the 5th level of glow is enabled.
If true, the 6th level of glow is enabled.
If true, the 7th level of glow is enabled. This is the most "global" level (blurriest).
The glow intensity. When using the GLES2 renderer, this should be increased to 1.5 to compensate for the lack of HDR rendering.
The glow strength. When using the GLES2 renderer, this should be increased to 1.3 to compensate for the lack of HDR rendering.
The bloom's intensity. If set to a value higher than 0, this will make glow visible in areas darker than the .
The glow blending mode.
The lower threshold of the HDR glow. When using the GLES2 renderer (which doesn't support HDR), this needs to be below 1.0 for glow to be visible. A value of 0.9 works well in this case.
The higher threshold of the HDR glow. Areas brighter than this threshold will be clamped for the purposes of the glow effect.
The bleed scale of the HDR glow.
Smooths out the blockiness created by sampling higher levels, at the cost of performance.
Note: When using the GLES2 renderer, this is only available if the GPU supports the GL_EXT_gpu_shader4 extension.
Takes more samples during downsample pass of glow. This ensures that single pixels are captured by glow which makes the glow look smoother and more stable during movement. However, it is very expensive and makes the glow post process take twice as long.
If true, enables the adjustment_* properties provided by this resource. If false, modifications to the adjustment_* properties will have no effect on the rendered scene.
The global brightness value of the rendered scene. Effective only if adjustment_enabled is true.
The global contrast value of the rendered scene (default value is 1). Effective only if adjustment_enabled is true.
The global color saturation value of the rendered scene (default value is 1). Effective only if adjustment_enabled is true.
Applies the provided resource to affect the global color aspect of the rendered scene. Effective only if adjustment_enabled is true.
Enables or disables the glow level at index idx. Each level relies on the previous level. This means that enabling higher glow levels will slow down the glow effect rendering, even if previous levels aren't enabled.
Returns true if the glow level idx is specified, false otherwise.
An expression can be made of any arithmetic operation, built-in math function call, method call of a passed instance, or built-in type construction call.
An example expression text using the built-in math functions could be sqrt(pow(3,2) + pow(4,2)).
In the following example we use a node to write our expression and show the result.
onready var expression = Expression.new()
func _ready():
$LineEdit.connect("text_entered", self, "_on_text_entered")
func _on_text_entered(command):
var error = expression.parse(command, [])
if error != OK:
print(expression.get_error_text())
return
var result = expression.execute([], null, true)
if not expression.has_execute_failed():
$LineEdit.text = str(result)
Parses the expression and returns an code.
You can optionally specify names of variables that may appear in the expression with input_names, so that you can bind them when it gets executed.
If the parameter is null, then the default value is Array.Empty<string>()
Executes the expression that was previously parsed by and returns the result. Before you use the returned object, you should check if the method failed by calling .
If you defined input variables in , you can specify their values in the inputs array, in the same order.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Returns true if has failed.
Returns the error text if has failed.
Enable support for the OpenGL ES external texture extension as defined by OES_EGL_image_external.
Note: This is only supported for Android platforms.
External texture size.
Returns the external texture name.
FileDialog is a preset dialog used to choose files and directories in the filesystem. It supports filter masks. The FileDialog automatically sets its window title according to the . If you want to use a custom title, disable this by setting to false.
The dialog allows selecting one, and only one file.
The dialog allows selecting multiple files.
The dialog only allows selecting a directory, disallowing the selection of any file.
The dialog allows selecting one file or directory.
The dialog will warn when a file exists.
The dialog only allows accessing files under the path (res://).
The dialog only allows accessing files under user data path (user://).
The dialog allows accessing files on the whole file system.
If true, changing the Mode property will set the window title accordingly (e.g. setting mode to will change the window title to "Open a File").
The dialog's open or save mode, which affects the selection behavior. See enum Mode constants.
The file system access scope. See enum Access constants.
Warning: Currently, in sandboxed environments such as HTML5 builds or sandboxed macOS apps, FileDialog cannot access the host file system. See godot-proposals#1123.
The available file type filters. For example, this shows only .png and .gd files: set_filters(PoolStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"])). Multiple file types can also be specified in a single filter. "*.png, *.jpg, *.jpeg ; Supported Images" will show both PNG and JPEG files when selected.
If true, the dialog will show hidden files.
The current working directory of the file dialog.
The currently selected file of the file dialog.
The currently selected file path of the file dialog.
Clear all the added filters in the dialog.
Adds filter to the list of filters, which restricts what files can be picked.
A filter should be of the form "filename.extension ; Description", where filename and extension can be * to match any string. Filters starting with . (i.e. empty filenames) are not allowed.
Example filters: "*.png ; PNG Images", "project.godot ; Godot Project".
Returns the vertical box container of the dialog, custom controls can be added to it.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Returns the LineEdit for the selected file.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Clear currently selected items in the dialog.
Invalidate and update the current dialog content list.
Arranges child nodes vertically or horizontally in a left-to-right or top-to-bottom flow.
A line is filled with nodes until no more fit on the same line, similar to text in an autowrapped label.
Returns the current line count.
Font contains a Unicode-compatible character set, as well as the ability to draw it with variable width, ascent, descent and kerning. For creating fonts from TTF files (or other font formats), see the editor support for fonts.
Note: If a doesn't contain a character used in a string, the character in question will be replaced with codepoint 0xfffd if it's available in the . If this replacement character isn't available in the DynamicFont, the character will be hidden without displaying any replacement character in the string.
Note: If a doesn't contain a character used in a string, the character in question will be hidden without displaying any replacement character in the string.
Note: Unicode characters after 0xffff (such as most emoji) are not supported on Windows. They will display as unknown characters instead. This will be resolved in Godot 4.0.
Contour point is on the curve.
Contour point isn't on the curve, but serves as a control point for a conic (quadratic) Bézier arc.
Contour point isn't on the curve, but serves as a control point for a cubic Bézier arc.
Draw string into a canvas item using the font at a given position, with modulate color, and optionally clipping the width. position specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis.
See also .
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Returns the font ascent (number of pixels above the baseline).
Returns the font descent (number of pixels below the baseline).
Returns the total font height (ascent plus descent) in pixels.
Returns the size of a character, optionally taking kerning into account if the next character is provided. Note that the height returned is the font height (see ) and has no relation to the glyph height.
Returns the size of a string, taking kerning and advance into account. Note that the height returned is the font height (see ) and has no relation to the string.
Returns the size that the string would have with word wrapping enabled with a fixed width.
Returns true if the font has an outline.
Draw character char into a canvas item using the font at a given position, with modulate color, and optionally kerning if next is passed. clipping the width. position specifies the baseline, not the top. To draw from the top, ascent must be added to the Y axis. The width used by the character is returned, making this function useful for drawing strings character by character.
If outline is true, the outline of the character is drawn instead of the character itself.
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Returns resource id of the cache texture containing the char.
Returns size of the cache texture containing the char.
Returns char offset from the baseline.
Returns size of the char.
Returns rectangle in the cache texture containing the char.
After editing a font (changing size, ascent, char rects, etc.). Call this function to propagate changes to controls that might use it.
Returns outline contours of the glyph as a Dictionary with the following contents:
points - , containing outline points. x and y are point coordinates. z is the type of the point, using the values.
contours - , containing indices the end points of each contour.
orientation - , contour orientation. If true, clockwise contours must be filled.
In GDScript, functions are not first-class objects. This means it is impossible to store them directly as variables, return them from another function, or pass them as arguments.
However, by creating a using the @GDScript.funcref function, a reference to a function in a given object can be created, passed around and called.
The name of the referenced function.
Calls the referenced function previously set in or @GDScript.funcref.
Calls the referenced function previously set in or @GDScript.funcref. Contrarily to , this method does not support a variable number of arguments but expects all parameters to be passed via a single .
The object containing the referenced function. This object must be of a type actually inheriting from , not a built-in type such as , or .
Returns whether the object still exists and has the function assigned.
A GDNative library can implement s, global functions to call with the class, or low-level engine extensions through interfaces such as . The library must be compiled for each platform and architecture that the project will run on.
This resource in INI-style format, as in .gdnlib files.
If true, Godot loads only one copy of the library and each script that references the library will share static data like static or global variables.
If false, Godot loads a separate copy of the library into memory for each script that references it.
If true, Godot loads the library at startup rather than the first time a script uses the library, calling {prefix}gdnative_singleton after initializing the library (where {prefix} is the value of ). The library remains loaded as long as Godot is running.
Note: A singleton library cannot be .
The prefix this library's entry point functions begin with. For example, a GDNativeLibrary would declare its gdnative_init function as godot_gdnative_init by default.
On platforms that require statically linking libraries (currently only iOS), each library must have a different symbol_prefix.
If true, the editor will temporarily unload the library whenever the user switches away from the editor window, allowing the user to recompile the library without restarting Godot.
Note: If the library defines tool scripts that run inside the editor, reloadable must be false. Otherwise, the editor will attempt to unload the tool scripts while they're in use and crash.
Returns the path to the dynamic library file for the current platform and architecture.
Returns paths to all dependency libraries for the current platform and architecture.
A script implemented in the GDScript programming language. The script extends the functionality of all objects that instance it.
creates a new instance of the script. extends an existing object, if that object's class matches one of the script's base classes.
Returns a new instance of the script.
For example:
var MyClass = load("myclass.gd")
var instance = MyClass.new()
assert(instance.get_script() == MyClass)
Returns byte code for the script source code.
Calling @GDScript.yield within a function will cause that function to yield and return its current state as an object of this type. The yielded function call can then be resumed later by calling on this state object.
Resume execution of the yielded function call.
If handed an argument, return the argument from the @GDScript.yield call in the yielded function call. You can pass e.g. an to hand multiple arguments.
This function returns what the resumed function call returns, possibly another function state if yielded again.
Check whether the function call may be resumed. This is not the case if the function state was already resumed.
If extended_check is enabled, it also checks if the associated script and object still exist. The extended check is done in debug mode as part of , but you can use this if you know you may be trying to resume without knowing for sure the object and/or script have survived up to that point.
s are used to provide high-quality real-time indirect light to scenes. They precompute the effect of objects that emit light and the effect of static geometry to simulate the behavior of complex light in real-time. s need to be baked before using, however, once baked, dynamic objects will receive light from them. Further, lights can be fully dynamic or baked.
Having s in a scene can be expensive, the quality of the probe can be turned down in exchange for better performance in the using .
Procedural generation: can be baked in an exported project, which makes it suitable for procedurally generated or user-built levels as long as all the geometry is generated in advance.
Performance: is relatively demanding on the GPU and is not suited to low-end hardware such as integrated graphics (consider instead). To provide a fallback for low-end hardware, consider adding an option to disable in your project's options menus. A node can be disabled by hiding it.
Note: Meshes should have sufficiently thick walls to avoid light leaks (avoid one-sided walls). For interior levels, enclose your level geometry in a sufficiently large box and bridge the loops to close the mesh. To further prevent light leaks, you can also strategically place temporary nodes with enabled. These temporary nodes can then be hidden after baking the node.
Note: Due to a renderer limitation, emissive s cannot emit light when used in a . Only emissive s can emit light in a .
Use 64 subdivisions. This is the lowest quality setting, but the fastest. Use it if you can, but especially use it on lower-end hardware.
Use 128 subdivisions. This is the default quality setting.
Use 256 subdivisions.
Use 512 subdivisions. This is the highest quality setting, but the slowest. On lower-end hardware, this could cause the GPU to stall.
Represents the size of the enum.
Number of times to subdivide the grid that the operates on. A higher number results in finer detail and thus higher visual quality, while lower numbers result in better performance.
The size of the area covered by the . If you make the extents larger without increasing the subdivisions with , the size of each cell will increase and result in lower detailed lighting.
The maximum brightness that the will recognize. Brightness will be scaled within this range.
Energy multiplier. Makes the lighting contribution from the brighter.
How much light propagates through the probe internally. A higher value allows light to spread further.
Offsets the lookup of the light contribution from the . This can be used to avoid self-shadowing, but may introduce light leaking at higher values. This and should be played around with to minimize self-shadowing and light leaking.
Note: bias should usually be above 1.0 as that is the size of the voxels.
Offsets the lookup into the based on the object's normal direction. Can be used to reduce some self-shadowing artifacts.
If true, ignores the sky contribution when calculating lighting.
Deprecated. This property has been deprecated due to known bugs and no longer has any effect when enabled.
The resource that holds the data for this .
Bakes the effect from all s marked with and s marked with either or . If create_visual_debug is true, after baking the light, this will generate a that has a cube representing each solid cell with each cube colored to the cell's albedo color. This can be used to visualize the 's data and debug any issues that may be occurring.
Note: works from the editor and in exported projects. This makes it suitable for procedurally generated or user-built levels. Baking a generally takes from 5 to 20 seconds in most scenes. Reducing can speed up baking.
Note: s and s must be fully ready before is called. If you are procedurally creating those and some meshes or lights are missing from your baked , use call_deferred("bake") instead of calling directly.
Calls with create_visual_debug enabled.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
The of the light. Defaults to white. A black color causes the light to have no effect.
The intensity of the light. This is expressed in candelas (lumens per steradian) for point and spot lights, and lux (lumens per m²) for directional lights. When creating a Godot light, this value is converted to a unitless multiplier.
The type of the light. The values accepted by Godot are "point", "spot", and "directional", which correspond to Godot's , , and respectively.
The range of the light, beyond which the light has no effect. GLTF lights with no range defined behave like physical lights (which have infinite range). When creating a Godot light, the range is clamped to 4096.
The inner angle of the cone in a spotlight. Must be less than or equal to the outer cone angle.
Within this angle, the light is at full brightness. Between the inner and outer cone angles, there is a transition from full brightness to zero brightness. When creating a Godot , the ratio between the inner and outer cone angles is used to calculate the attenuation of the light.
The outer angle of the cone in a spotlight. Must be greater than or equal to the inner angle.
At this angle, the light drops off to zero brightness. Between the inner and outer cone angles, there is a transition from full brightness to zero brightness. If this angle is a half turn, then the spotlight emits in all directions. When creating a Godot , the outer cone angle is used as the angle of the spotlight.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
The first 3 DOF axes are linear axes, which represent translation of Bodies, and the latter 3 DOF axes represent the angular motion. Each axis can be either locked, or limited.
The minimum difference between the pivot points' axes.
The maximum difference between the pivot points' axes.
A factor applied to the movement across the axes. The lower, the slower the movement.
The amount of restitution on the axes' movement. The lower, the more momentum gets lost.
The amount of damping that happens at the linear motion across the axes.
The velocity the linear motor will try to reach.
The maximum force the linear motor will apply while trying to reach the velocity target.
The minimum rotation in negative direction to break loose and rotate around the axes.
The minimum rotation in positive direction to break loose and rotate around the axes.
The speed of all rotations across the axes.
The amount of rotational damping across the axes. The lower, the more dampening occurs.
The amount of rotational restitution across the axes. The lower, the more restitution occurs.
The maximum amount of force that can occur, when rotating around the axes.
When rotating across the axes, this error tolerance factor defines how much the correction gets slowed down. The lower, the slower.
Target speed for the motor at the axes.
Maximum acceleration for the motor at the axes.
Represents the size of the enum.
If enabled, linear motion is possible within the given limits.
If enabled, rotational motion is possible within the given limits.
If enabled, there is a rotational motor across these axes.
If enabled, there is a linear motor across these axes.
Represents the size of the enum.
If true, the linear motion across the X axis is limited.
The maximum difference between the pivot points' X axis.
The minimum difference between the pivot points' X axis.
A factor applied to the movement across the X axis. The lower, the slower the movement.
The amount of restitution on the X axis movement. The lower, the more momentum gets lost.
The amount of damping that happens at the X motion.
If true, then there is a linear motor on the X axis. It will attempt to reach the target velocity while staying within the force limits.
The speed that the linear motor will attempt to reach on the X axis.
The maximum force the linear motor can apply on the X axis while trying to reach the target velocity.
If true, rotation across the X axis is limited.
The minimum rotation in positive direction to break loose and rotate around the X axis.
The minimum rotation in negative direction to break loose and rotate around the X axis.
The speed of all rotations across the X axis.
The amount of rotational restitution across the X axis. The lower, the more restitution occurs.
The amount of rotational damping across the X axis.
The lower, the longer an impulse from one side takes to travel to the other side.
The maximum amount of force that can occur, when rotating around the X axis.
When rotating across the X axis, this error tolerance factor defines how much the correction gets slowed down. The lower, the slower.
If true, a rotating motor at the X axis is enabled.
Target speed for the motor at the X axis.
Maximum acceleration for the motor at the X axis.
If true, the linear motion across the Y axis is limited.
The maximum difference between the pivot points' Y axis.
The minimum difference between the pivot points' Y axis.
A factor applied to the movement across the Y axis. The lower, the slower the movement.
The amount of restitution on the Y axis movement. The lower, the more momentum gets lost.
The amount of damping that happens at the Y motion.
If true, then there is a linear motor on the Y axis. It will attempt to reach the target velocity while staying within the force limits.
The speed that the linear motor will attempt to reach on the Y axis.
The maximum force the linear motor can apply on the Y axis while trying to reach the target velocity.
If true, rotation across the Y axis is limited.
The minimum rotation in positive direction to break loose and rotate around the Y axis.
The minimum rotation in negative direction to break loose and rotate around the Y axis.
The speed of all rotations across the Y axis.
The amount of rotational restitution across the Y axis. The lower, the more restitution occurs.
The amount of rotational damping across the Y axis. The lower, the more dampening occurs.
The maximum amount of force that can occur, when rotating around the Y axis.
When rotating across the Y axis, this error tolerance factor defines how much the correction gets slowed down. The lower, the slower.
If true, a rotating motor at the Y axis is enabled.
Target speed for the motor at the Y axis.
Maximum acceleration for the motor at the Y axis.
If true, the linear motion across the Z axis is limited.
The maximum difference between the pivot points' Z axis.
The minimum difference between the pivot points' Z axis.
A factor applied to the movement across the Z axis. The lower, the slower the movement.
The amount of restitution on the Z axis movement. The lower, the more momentum gets lost.
The amount of damping that happens at the Z motion.
If true, then there is a linear motor on the Z axis. It will attempt to reach the target velocity while staying within the force limits.
The speed that the linear motor will attempt to reach on the Z axis.
The maximum force the linear motor can apply on the Z axis while trying to reach the target velocity.
If true, rotation across the Z axis is limited.
The minimum rotation in positive direction to break loose and rotate around the Z axis.
The minimum rotation in negative direction to break loose and rotate around the Z axis.
The speed of all rotations across the Z axis.
The amount of rotational restitution across the Z axis. The lower, the more restitution occurs.
The amount of rotational damping across the Z axis. The lower, the more dampening occurs.
The maximum amount of force that can occur, when rotating around the Z axis.
When rotating across the Z axis, this error tolerance factor defines how much the correction gets slowed down. The lower, the slower.
If true, a rotating motor at the Z axis is enabled.
Target speed for the motor at the Z axis.
Maximum acceleration for the motor at the Z axis.
Base node for geometry-based visual instances. Shares some common functionality like visibility and custom materials.
Will allow the GeometryInstance to be used when baking lights using a or .
Unused in this class, exposed for consistency with .
Represents the size of the enum.
Will not cast any shadows.
Will cast shadows from all visible faces in the GeometryInstance.
Will take culling into account, so faces not being rendered will not be taken into account when shadow casting.
Will cast shadows from all visible faces in the GeometryInstance.
Will not take culling into account, so all faces will be taken into account when shadow casting.
Will only show the shadows casted from this object.
In other words, the actual mesh will not be visible, only the shadows casted from the mesh will be.
The generated lightmap texture will have the original size.
The generated lightmap texture will be twice as large, on each axis.
The generated lightmap texture will be 4 times as large, on each axis.
The generated lightmap texture will be 8 times as large, on each axis.
The material override for the whole geometry.
If a material is assigned to this property, it will be used instead of any material set in any material slot of the mesh.
The material overlay for the whole geometry.
If a material is assigned to this property, it will be rendered on top of any other active material for all the surfaces.
The selected shadow casting flag. See for possible values.
The extra distance added to the GeometryInstance's bounding box () to increase its cull box.
If true, this GeometryInstance will be used when baking lights using a or .
When disabled, the mesh will be taken into account when computing indirect lighting, but the resulting lightmap will not be saved. Useful for emissive only materials or shadow casters.
Scale factor for the generated baked lightmap. Useful for adding detail to certain mesh instances.
The GeometryInstance's min LOD distance.
Note: This property currently has no effect.
The GeometryInstance's min LOD margin.
Note: This property currently has no effect.
The GeometryInstance's max LOD distance.
Note: This property currently has no effect.
The GeometryInstance's max LOD margin.
Note: This property currently has no effect.
Sets the specified. See for options.
Returns the that have been set for this object.
Overrides the bounding box of this node with a custom one. To remove it, set an with all fields set to zero.
Given a set of colors, this resource will interpolate them in order. This means that if you have color 1, color 2 and color 3, the gradient will interpolate from color 1 to color 2 and from color 2 to color 3. The gradient will initially have 2 colors (black and white), one (black) at gradient lower offset 0 and the other (white) at the gradient higher offset 1.
See also which supports more complex easing methods, but does not support colors.
Linear interpolation.
Constant interpolation, color changes abruptly at each point and stays uniform between. This might cause visible aliasing when used for a gradient texture in some cases.
Cubic interpolation.
Defines how the colors between points of the gradient are interpolated. See for available modes.
Gradient's offsets returned as a .
Gradient's colors returned as a .
Adds the specified color to the end of the ramp, with the specified offset.
Removes the color at the index point.
Sets the offset for the ramp color at index point.
Returns the offset of the ramp color at index point.
Sets the color of the ramp color at index point.
Returns the color of the ramp color at index point.
Returns the interpolated color specified by offset.
Returns the number of colors in the ramp.
GradientTexture uses a to fill the texture data. The gradient will be filled from left to right using colors obtained from the gradient. This means the texture does not necessarily represent an exact copy of the gradient, but instead an interpolation of samples obtained from the gradient at fixed steps (see ). See also and .
The that will be used to fill the texture.
The number of color samples that will be obtained from the .
The texture uses a to fill the texture data in 2D space. The gradient is filled according to the specified and types using colors obtained from the gradient. The texture does not necessarily represent an exact copy of the gradient, but instead an interpolation of samples obtained from the gradient at fixed steps (see and ). See also and .
The colors are linearly interpolated in a straight line.
The colors are linearly interpolated in a circular pattern.
The gradient fill is restricted to the range defined by to offsets.
The texture is filled starting from to offsets, repeating the same pattern in both directions.
The texture is filled starting from to offsets, mirroring the pattern in both directions.
The used to fill the texture.
The number of horizontal color samples that will be obtained from the , which also represents the texture's width.
The number of vertical color samples that will be obtained from the , which also represents the texture's height.
If true, the generated texture will support high dynamic range ( format). This allows for glow effects to work if is true. If false, the generated texture will use low dynamic range; overbright colors will be clamped ( format).
The gradient fill type, one of the values. The texture is filled by interpolating colors starting from to offsets.
The initial offset used to fill the texture specified in UV coordinates.
The final offset used to fill the texture specified in UV coordinates.
The gradient repeat type, one of the values. The texture is filled starting from to offsets by default, but the gradient fill can be repeated to cover the entire texture.
GraphEdit manages the showing of GraphNodes it contains, as well as connections and disconnections between them. Signals are sent for each of these two events. Disconnection between GraphNode slots is disabled by default.
It is greatly advised to enable low-processor usage mode (see ) when using GraphEdits.
If true, enables disconnection of existing connections in the GraphEdit by dragging the right end.
The scroll offset.
The snapping distance in pixels.
If true, enables snapping.
The current zoom value.
The lower zoom limit.
The upper zoom limit.
The step of each zoom level.
If true, makes a label with the current zoom level visible. The zoom value is displayed in percents.
If true, the minimap is visible.
The size of the minimap rectangle. The map itself is based on the size of the grid area and is scaled to fit this rectangle.
The opacity of the minimap rectangle.
Create a connection between the from_port slot of the from GraphNode and the to_port slot of the to GraphNode. If the connection already exists, no connection is created.
Returns true if the from_port slot of the from GraphNode is connected to the to_port slot of the to GraphNode.
Removes the connection between the from_port slot of the from GraphNode and the to_port slot of the to GraphNode. If the connection does not exist, no connection is removed.
Sets the coloration of the connection between from's from_port and to's to_port with the color provided in the activity theme property.
Returns an Array containing the list of connections. A connection consists in a structure of the form { from_port: 0, from: "GraphNode name 0", to_port: 1, to: "GraphNode name 1" }.
Removes all connections between nodes.
Makes possible to disconnect nodes when dragging from the slot at the right if it has the specified type.
Removes the possibility to disconnect nodes when dragging from the slot at the right if it has the specified type.
Makes possible to disconnect nodes when dragging from the slot at the left if it has the specified type.
Removes the possibility to disconnect nodes when dragging from the slot at the left if it has the specified type.
Makes possible the connection between two different slot types. The type is defined with the method.
Makes it not possible to connect between two different slot types. The type is defined with the method.
Returns whether it's possible to connect slots of the specified types.
Gets the that contains the zooming and grid snap controls in the top left of the graph. You can use this method to reposition the toolbar or to add your own custom controls to it.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Sets the specified node as the one selected.
A GraphNode is a container. Each GraphNode can have several input and output slots, sometimes referred to as ports, allowing connections between GraphNodes. To add a slot to GraphNode, add any -derived child node to it.
After adding at least one child to GraphNode new sections will be automatically created in the Inspector called 'Slot'. When 'Slot' is expanded you will see list with index number for each slot. You can click on each of them to expand further.
In the Inspector you can enable (show) or disable (hide) slots. By default, all slots are disabled so you may not see any slots on your GraphNode initially. You can assign a type to each slot. Only slots of the same type will be able to connect to each other. You can also assign colors to slots. A tuple of input and output slots is defined for each GUI element included in the GraphNode. Input connections are on the left and output connections are on the right side of GraphNode. Only enabled slots are counted as connections.
No overlay is shown.
Show overlay set in the breakpoint theme property.
Show overlay set in the position theme property.
The text displayed in the GraphNode's title bar.
The offset of the GraphNode, relative to the scroll offset of the .
Note: You cannot use position directly, as is a .
If true, the close button will be visible.
Note: Pressing it will only emit the close_request signal, the GraphNode needs to be removed manually.
If true, the user can resize the GraphNode.
Note: Dragging the handle will only emit the resize_request signal, the GraphNode needs to be resized manually.
If true, the GraphNode is selected.
If true, the GraphNode is a comment node.
Sets the overlay shown above the GraphNode. See .
Sets properties of the slot with ID idx.
If enable_left/right, a port will appear and the slot will be able to be connected from this side.
type_left/right is an arbitrary type of the port. Only ports with the same type values can be connected.
color_left/right is the tint of the port's icon on this side.
custom_left/right is a custom texture for this side's port.
Note: This method only sets properties of the slot. To create the slot, add a -derived child to the GraphNode.
Individual properties can be set using one of the set_slot_* methods. You must enable at least one side of the slot to do so.
Disables input and output slot whose index is idx.
Disables all input and output slots of the GraphNode.
Returns true if left (input) side of the slot idx is enabled.
Toggles the left (input) side of the slot idx. If enable_left is true, a port will appear on the left side and the slot will be able to be connected from this side.
Sets the left (input) type of the slot idx to type_left.
Returns the left (input) type of the slot idx.
Sets the of the left (input) side of the slot idx to color_left.
Returns the left (input) of the slot idx.
Returns true if right (output) side of the slot idx is enabled.
Toggles the right (output) side of the slot idx. If enable_right is true, a port will appear on the right side and the slot will be able to be connected from this side.
Sets the right (output) type of the slot idx to type_right.
Returns the right (output) type of the slot idx.
Sets the of the right (output) side of the slot idx to color_right.
Returns the right (output) of the slot idx.
Returns the number of enabled output slots (connections) of the GraphNode.
Returns the number of enabled input slots (connections) to the GraphNode.
Returns the position of the output connection idx.
Returns the type of the output connection idx.
Returns the of the output connection idx.
Returns the position of the input connection idx.
Returns the type of the input connection idx.
Returns the of the input connection idx.
GridContainer will arrange its Control-derived children in a grid like structure, the grid columns are specified using the property and the number of rows will be equal to the number of children in the container divided by the number of columns. For example, if the container has 5 children, and 2 columns, there will be 3 rows in the container.
Notice that grid layout will preserve the columns and rows for every size of the container, and that empty columns will be expanded automatically.
Note: GridContainer only works with child nodes inheriting from Control. It won't rearrange child nodes inheriting from Node2D.
The number of columns in the . If modified, reorders its Control-derived children to accommodate the new layout.
GridMap lets you place meshes on a grid interactively. It works both from the editor and from scripts, which can help you create in-game level editors.
GridMaps use a which contains a list of tiles. Each tile is a mesh with materials plus optional collision and navigation shapes.
A GridMap contains a collection of cells. Each grid cell refers to a tile in the . All cells in the map have the same dimensions.
Internally, a GridMap is split into a sparse collection of octants for efficient rendering and physics processing. Every octant has the same dimensions and can contain several cells.
Note: GridMap doesn't extend and therefore can't be hidden or cull masked based on . If you make a light not affect the first layer, the whole GridMap won't be lit by the light in question.
Invalid cell item that can be used in to clear cells (or represent an empty cell in ).
The assigned .
Overrides the default friction and bounce physics properties for the whole .
Controls whether this GridMap will be baked in a or not.
The dimensions of the grid's cells.
This does not affect the size of the meshes. See .
The size of each octant measured in number of cells. This applies to all three axis.
If true, grid items are centered on the X axis.
If true, grid items are centered on the Y axis.
If true, grid items are centered on the Z axis.
The scale of the cell items.
This does not affect the size of the grid cells themselves, only the items in them. This can be used to make cell items overlap their neighbors.
The physics layers this GridMap is in.
GridMaps act as static bodies, meaning they aren't affected by gravity or other forces. They only affect other physics bodies that collide with them.
The physics layers this GridMap detects collisions in. See Collision layers and masks in the documentation for more information.
If true, this GridMap uses cell navmesh resources to create navigation regions.
The navigation layers the GridMap generates its navigation regions in.
Sets an individual bit on the .
Returns an individual bit on the .
Sets an individual bit on the .
Returns an individual bit on the .
Sets the mesh index for the cell referenced by its grid-based X, Y and Z coordinates.
A negative item index such as will clear the cell.
Optionally, the item's orientation can be passed. For valid orientation values, see Basis.get_orthogonal_index.
The item index located at the grid-based X, Y and Z coordinates. If the cell is empty, will be returned.
The orientation of the cell at the grid-based X, Y and Z coordinates. -1 is returned if the cell is empty.
Returns the coordinates of the grid cell containing the given point.
pos should be in the GridMap's local coordinate space.
Returns the position of a grid cell in the GridMap's local coordinate space.
Clear all cells.
Returns an array of with the non-empty cell coordinates in the grid map.
Returns an array of all cells with the given item index specified in item.
Returns an array of and references corresponding to the non-empty cells in the grid. The transforms are specified in world space.
Returns an array of es and references of all bake meshes that exist within the current GridMap.
Groove constraint for 2D physics. This is useful for making a body "slide" through a segment placed in another.
The groove's length. The groove is from the joint's origin towards along the joint's local Y axis.
The body B's initial anchor position defined by the joint's origin and a local offset along the joint's Y axis (along the groove).
Horizontal box container. See .
Horizontal version of .
The HMACContext class is useful for advanced HMAC use cases, such as streaming the message as it supports creating the message over time rather than providing it all at once.
extends Node
var ctx = HMACContext.new()
func _ready():
var key = "supersecret".to_utf8()
var err = ctx.start(HashingContext.HASH_SHA256, key)
assert(err == OK)
var msg1 = "this is ".to_utf8()
var msg2 = "super duper secret".to_utf8()
err = ctx.update(msg1)
assert(err == OK)
err = ctx.update(msg2)
assert(err == OK)
var hmac = ctx.finish()
print(hmac.hex_encode())
And in C# we can use the following.
using Godot;
using System;
using System.Diagnostics;
public class CryptoNode : Node
{
private HMACContext ctx = new HMACContext();
public override void _Ready()
{
PoolByteArray key = String("supersecret").to_utf8();
Error err = ctx.Start(HashingContext.HASH_SHA256, key);
GD.Assert(err == OK);
PoolByteArray msg1 = String("this is ").to_utf8();
PoolByteArray msg2 = String("super duper secret").to_utf8();
err = ctx.Update(msg1);
GD.Assert(err == OK);
err = ctx.Update(msg2);
GD.Assert(err == OK);
PoolByteArray hmac = ctx.Finish();
GD.Print(hmac.HexEncode());
}
}
Note: Not available in HTML5 exports.
Initializes the HMACContext. This method cannot be called again on the same HMACContext until has been called.
Updates the message to be HMACed. This can be called multiple times before is called to append data to the message, but cannot be called until has been called.
Returns the resulting HMAC. If the HMAC failed, an empty is returned.
Horizontal version of , which goes from left (min) to right (max).
Horizontal separator. See . Even though it looks horizontal, it is used to separate objects vertically.
Horizontal slider. See . This one goes from left (min) to right (max).
Note: The Range.changed and Range.value_changed signals are part of the class which this class inherits from.
Horizontal split container. See . This goes from left to right.
Hyper-text transfer protocol client (sometimes called "User Agent"). Used to make HTTP requests to download web content, upload files and other data or to communicate with various services, among other use cases.
See the node for a higher-level alternative.
Note: This client only needs to connect to a host once (see ) to send multiple requests. Because of this, methods that take URLs usually take just the part after the host instead of the full URL, as the client is already connected to a host. See for a full example and to get started.
A should be reused between multiple requests or to connect to different hosts instead of creating one client per request. Supports SSL and SSL server certificate verification. HTTP status codes in the 2xx range indicate success, 3xx redirection (i.e. "try again, but over here"), 4xx something was wrong with the request, and 5xx something went wrong on the server's side.
For more information on HTTP, see https://developer.mozilla.org/en-US/docs/Web/HTTP (or read RFC 2616 to get it straight from the source: https://tools.ietf.org/html/rfc2616).
Note: When performing HTTP requests from a project exported to HTML5, keep in mind the remote server may not allow requests from foreign origins due to CORS. If you host the server in question, you should modify its backend to allow requests from foreign origins by adding the Access-Control-Allow-Origin: * HTTP header.
Note: SSL/TLS support is currently limited to TLS 1.0, TLS 1.1, and TLS 1.2. Attempting to connect to a TLS 1.3-only server will return an error.
Warning: SSL/TLS certificate revocation and certificate pinning are currently not supported. Revoked certificates are accepted as long as they are otherwise valid. If this is a concern, you may want to use automatically managed certificates with a short validity period.
Status: Disconnected from the server.
Status: Currently resolving the hostname for the given URL into an IP.
Status: DNS failure: Can't resolve the hostname for the given URL.
Status: Currently connecting to server.
Status: Can't connect to the server.
Status: Connection established.
Status: Currently sending request.
Status: HTTP body received.
Status: Error in HTTP connection.
Status: Error in SSL handshake.
HTTP GET method. The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
HTTP HEAD method. The HEAD method asks for a response identical to that of a GET request, but without the response body. This is useful to request metadata like HTTP headers or to check if a resource exists.
HTTP POST method. The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server. This is often used for forms and submitting data or uploading files.
HTTP PUT method. The PUT method asks to replace all current representations of the target resource with the request payload. (You can think of POST as "create or update" and PUT as "update", although many services tend to not make a clear distinction or change their meaning).
HTTP DELETE method. The DELETE method requests to delete the specified resource.
HTTP OPTIONS method. The OPTIONS method asks for a description of the communication options for the target resource. Rarely used.
HTTP TRACE method. The TRACE method performs a message loop-back test along the path to the target resource. Returns the entire HTTP request received in the response body. Rarely used.
HTTP CONNECT method. The CONNECT method establishes a tunnel to the server identified by the target resource. Rarely used.
HTTP PATCH method. The PATCH method is used to apply partial modifications to a resource.
Represents the size of the enum.
HTTP status code 100 Continue. Interim response that indicates everything so far is OK and that the client should continue with the request (or ignore this status if already finished).
HTTP status code 101 Switching Protocol. Sent in response to an Upgrade request header by the client. Indicates the protocol the server is switching to.
HTTP status code 102 Processing (WebDAV). Indicates that the server has received and is processing the request, but no response is available yet.
HTTP status code 200 OK. The request has succeeded. Default response for successful requests. Meaning varies depending on the request. GET: The resource has been fetched and is transmitted in the message body. HEAD: The entity headers are in the message body. POST: The resource describing the result of the action is transmitted in the message body. TRACE: The message body contains the request message as received by the server.
HTTP status code 201 Created. The request has succeeded and a new resource has been created as a result of it. This is typically the response sent after a PUT request.
HTTP status code 202 Accepted. The request has been received but not yet acted upon. It is non-committal, meaning that there is no way in HTTP to later send an asynchronous response indicating the outcome of processing the request. It is intended for cases where another process or server handles the request, or for batch processing.
HTTP status code 203 Non-Authoritative Information. This response code means returned meta-information set is not exact set as available from the origin server, but collected from a local or a third party copy. Except this condition, 200 OK response should be preferred instead of this response.
HTTP status code 204 No Content. There is no content to send for this request, but the headers may be useful. The user-agent may update its cached headers for this resource with the new ones.
HTTP status code 205 Reset Content. The server has fulfilled the request and desires that the client resets the "document view" that caused the request to be sent to its original state as received from the origin server.
HTTP status code 206 Partial Content. This response code is used because of a range header sent by the client to separate download into multiple streams.
HTTP status code 207 Multi-Status (WebDAV). A Multi-Status response conveys information about multiple resources in situations where multiple status codes might be appropriate.
HTTP status code 208 Already Reported (WebDAV). Used inside a DAV: propstat response element to avoid enumerating the internal members of multiple bindings to the same collection repeatedly.
HTTP status code 226 IM Used (WebDAV). The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
HTTP status code 300 Multiple Choice. The request has more than one possible responses and there is no standardized way to choose one of the responses. User-agent or user should choose one of them.
HTTP status code 301 Moved Permanently. Redirection. This response code means the URI of requested resource has been changed. The new URI is usually included in the response.
HTTP status code 302 Found. Temporary redirection. This response code means the URI of requested resource has been changed temporarily. New changes in the URI might be made in the future. Therefore, this same URI should be used by the client in future requests.
HTTP status code 303 See Other. The server is redirecting the user agent to a different resource, as indicated by a URI in the Location header field, which is intended to provide an indirect response to the original request.
HTTP status code 304 Not Modified. A conditional GET or HEAD request has been received and would have resulted in a 200 OK response if it were not for the fact that the condition evaluated to false.
HTTP status code 305 Use Proxy. Deprecated. Do not use.
HTTP status code 306 Switch Proxy. Deprecated. Do not use.
HTTP status code 307 Temporary Redirect. The target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI.
HTTP status code 308 Permanent Redirect. The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.
HTTP status code 400 Bad Request. The request was invalid. The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, invalid request contents, or deceptive request routing).
HTTP status code 401 Unauthorized. Credentials required. The request has not been applied because it lacks valid authentication credentials for the target resource.
HTTP status code 402 Payment Required. This response code is reserved for future use. Initial aim for creating this code was using it for digital payment systems, however this is not currently used.
HTTP status code 403 Forbidden. The client does not have access rights to the content, i.e. they are unauthorized, so server is rejecting to give proper response. Unlike 401, the client's identity is known to the server.
HTTP status code 404 Not Found. The server can not find requested resource. Either the URL is not recognized or the endpoint is valid but the resource itself does not exist. May also be sent instead of 403 to hide existence of a resource if the client is not authorized.
HTTP status code 405 Method Not Allowed. The request's HTTP method is known by the server but has been disabled and cannot be used. For example, an API may forbid DELETE-ing a resource. The two mandatory methods, GET and HEAD, must never be disabled and should not return this error code.
HTTP status code 406 Not Acceptable. The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request. Used when negotiation content.
HTTP status code 407 Proxy Authentication Required. Similar to 401 Unauthorized, but it indicates that the client needs to authenticate itself in order to use a proxy.
HTTP status code 408 Request Timeout. The server did not receive a complete request message within the time that it was prepared to wait.
HTTP status code 409 Conflict. The request could not be completed due to a conflict with the current state of the target resource. This code is used in situations where the user might be able to resolve the conflict and resubmit the request.
HTTP status code 410 Gone. The target resource is no longer available at the origin server and this condition is likely permanent.
HTTP status code 411 Length Required. The server refuses to accept the request without a defined Content-Length header.
HTTP status code 412 Precondition Failed. One or more conditions given in the request header fields evaluated to false when tested on the server.
HTTP status code 413 Entity Too Large. The server is refusing to process a request because the request payload is larger than the server is willing or able to process.
HTTP status code 414 Request-URI Too Long. The server is refusing to service the request because the request-target is longer than the server is willing to interpret.
HTTP status code 415 Unsupported Media Type. The origin server is refusing to service the request because the payload is in a format not supported by this method on the target resource.
HTTP status code 416 Requested Range Not Satisfiable. None of the ranges in the request's Range header field overlap the current extent of the selected resource or the set of ranges requested has been rejected due to invalid ranges or an excessive request of small or overlapping ranges.
HTTP status code 417 Expectation Failed. The expectation given in the request's Expect header field could not be met by at least one of the inbound servers.
HTTP status code 418 I'm A Teapot. Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot". The resulting entity body MAY be short and stout.
HTTP status code 421 Misdirected Request. The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI.
HTTP status code 422 Unprocessable Entity (WebDAV). The server understands the content type of the request entity (hence a 415 Unsupported Media Type status code is inappropriate), and the syntax of the request entity is correct (thus a 400 Bad Request status code is inappropriate) but was unable to process the contained instructions.
HTTP status code 423 Locked (WebDAV). The source or destination resource of a method is locked.
HTTP status code 424 Failed Dependency (WebDAV). The method could not be performed on the resource because the requested action depended on another action and that action failed.
HTTP status code 426 Upgrade Required. The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.
HTTP status code 428 Precondition Required. The origin server requires the request to be conditional.
HTTP status code 429 Too Many Requests. The user has sent too many requests in a given amount of time (see "rate limiting"). Back off and increase time between requests or try again later.
HTTP status code 431 Request Header Fields Too Large. The server is unwilling to process the request because its header fields are too large. The request MAY be resubmitted after reducing the size of the request header fields.
HTTP status code 451 Response Unavailable For Legal Reasons. The server is denying access to the resource as a consequence of a legal demand.
HTTP status code 500 Internal Server Error. The server encountered an unexpected condition that prevented it from fulfilling the request.
HTTP status code 501 Not Implemented. The server does not support the functionality required to fulfill the request.
HTTP status code 502 Bad Gateway. The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request. Usually returned by load balancers or proxies.
HTTP status code 503 Service Unavailable. The server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay. Try again later.
HTTP status code 504 Gateway Timeout. The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request. Usually returned by load balancers or proxies.
HTTP status code 505 HTTP Version Not Supported. The server does not support, or refuses to support, the major version of HTTP that was used in the request message.
HTTP status code 506 Variant Also Negotiates. The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.
HTTP status code 507 Insufficient Storage. The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.
HTTP status code 508 Loop Detected. The server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". This status indicates that the entire operation failed.
HTTP status code 510 Not Extended. The policy for accessing the resource has not been met in the request. The server should send back all the information necessary for the client to issue an extended request.
HTTP status code 511 Network Authentication Required. The client needs to authenticate to gain network access.
If true, execution will block until all data is read from the response.
The connection to use for this client.
The size of the buffer used and maximum bytes to read per iteration. See .
Connects to a host. This needs to be done before any requests are sent.
The host should not have http:// prepended but will strip the protocol identifier if provided.
If no port is specified (or -1 is used), it is automatically set to 80 for HTTP and 443 for HTTPS (if use_ssl is enabled).
verify_host will check the SSL identity of the host if set to true.
Sends a raw request to the connected host.
The URL parameter is usually just the part after the host, so for http://somehost.com/index.php, it is /index.php. When sending requests to an HTTP proxy server, it should be an absolute URL. For requests, * is also allowed. For requests, it should be the authority component (host:port).
Headers are HTTP request headers. For available HTTP methods, see .
Sends the body data raw, as a byte array and does not encode it in any way.
Sends a request to the connected host.
The URL parameter is usually just the part after the host, so for http://somehost.com/index.php, it is /index.php. When sending requests to an HTTP proxy server, it should be an absolute URL. For requests, * is also allowed. For requests, it should be the authority component (host:port).
Headers are HTTP request headers. For available HTTP methods, see .
To create a POST request with query strings to push to the server, do:
var fields = {"username" : "user", "password" : "pass"}
var query_string = http_client.query_string_from_dict(fields)
var headers = ["Content-Type: application/x-www-form-urlencoded", "Content-Length: " + str(query_string.length())]
var result = http_client.request(http_client.METHOD_POST, "/index.php", headers, query_string)
Note: The request_data parameter is ignored if method is . This is because GET methods can't contain request data. As a workaround, you can pass request data as a query string in the URL. See String.http_escape for an example.
Closes the current connection, allowing reuse of this .
If true, this has a response available.
If true, this has a response that is chunked.
Returns the response's HTTP status code.
Returns the response headers.
Returns all response headers as a Dictionary of structure { "key": "value1; value2" } where the case-sensitivity of the keys and values is kept like the server delivers it. A value is a simple String, this string can have more than one value where "; " is used as separator.
Example:
{
"content-length": 12,
"Content-Type": "application/json; charset=UTF-8",
}
Returns the response's body length.
Note: Some Web servers may not send a body length. In this case, the value returned will be -1. If using chunked transfer encoding, the body length will also be -1.
Reads one chunk from the response.
Returns a constant. Need to call in order to get status updates.
This needs to be called in order to have any request processed. Check results with .
Sets the proxy server for HTTP requests.
The proxy server is unset if host is empty or port is -1.
Sets the proxy server for HTTPS requests.
The proxy server is unset if host is empty or port is -1.
Generates a GET/POST application/x-www-form-urlencoded style query string from a provided dictionary, e.g.:
var fields = {"username": "user", "password": "pass"}
var query_string = http_client.query_string_from_dict(fields)
# Returns "username=user&password=pass"
Furthermore, if a key has a null value, only the key itself is added, without equal sign and value. If the value is an array, for each value in it a pair with the same key is added.
var fields = {"single": 123, "not_valued": null, "multiple": [22, 33, 44]}
var query_string = http_client.query_string_from_dict(fields)
# Returns "single=123¬_valued&multiple=22&multiple=33&multiple=44"
A node with the ability to send HTTP requests. Uses internally.
Can be used to make HTTP requests, i.e. download or upload files or web content via HTTP.
Warning: See the notes and warnings on for limitations, especially regarding SSL security.
Example of contacting a REST API and printing one of its returned fields:
func _ready():
# Create an HTTP request node and connect its completion signal.
var http_request = HTTPRequest.new()
add_child(http_request)
http_request.connect("request_completed", self, "_http_request_completed")
# Perform a GET request. The URL below returns JSON as of writing.
var error = http_request.request("https://httpbin.org/get")
if error != OK:
push_error("An error occurred in the HTTP request.")
# Perform a POST request. The URL below returns JSON as of writing.
# Note: Don't make simultaneous requests using a single HTTPRequest node.
# The snippet below is provided for reference only.
var body = to_json({"name": "Godette"})
error = http_request.request("https://httpbin.org/post", [], true, HTTPClient.METHOD_POST, body)
if error != OK:
push_error("An error occurred in the HTTP request.")
# Called when the HTTP request is completed.
func _http_request_completed(result, response_code, headers, body):
var response = parse_json(body.get_string_from_utf8())
# Will print the user agent string used by the HTTPRequest node (as recognized by httpbin.org).
print(response.headers["User-Agent"])
Example of loading and displaying an image using HTTPRequest:
func _ready():
# Create an HTTP request node and connect its completion signal.
var http_request = HTTPRequest.new()
add_child(http_request)
http_request.connect("request_completed", self, "_http_request_completed")
# Perform the HTTP request. The URL below returns a PNG image as of writing.
var error = http_request.request("https://via.placeholder.com/512")
if error != OK:
push_error("An error occurred in the HTTP request.")
# Called when the HTTP request is completed.
func _http_request_completed(result, response_code, headers, body):
var image = Image.new()
var error = image.load_png_from_buffer(body)
if error != OK:
push_error("Couldn't load the image.")
var texture = ImageTexture.new()
texture.create_from_image(image)
# Display the image in a TextureRect node.
var texture_rect = TextureRect.new()
add_child(texture_rect)
texture_rect.texture = texture
Request successful.
Request failed while connecting.
Request failed while resolving.
Request failed due to connection (read/write) error.
Request failed on SSL handshake.
Request does not have a response (yet).
Request exceeded its maximum size limit, see .
Request failed (currently unused).
HTTPRequest couldn't open the download file.
HTTPRequest couldn't write to the download file.
Request reached its maximum redirect limit, see .
The file to download into. If set to a non-empty string, the request output will be written to the file located at the path. If a file already exists at the specified location, it will be overwritten as soon as body data begins to be received.
Note: Folders are not automatically created when the file is created. If points to a subfolder, it's recommended to create the necessary folders beforehand using to ensure the file can be written.
The size of the buffer used and maximum bytes to read per iteration. See .
Set this to a lower value (e.g. 4096 for 4 KiB) when downloading small files to decrease memory usage at the cost of download speeds.
If true, multithreading is used to improve performance.
Maximum allowed size for response bodies (-1 means no limit). When only small files are expected, this can be used to prevent disallow receiving files that are too large, preventing potential denial of service attacks.
Maximum number of allowed redirects. This is used to prevent endless redirect loops.
If set to a value greater than 0.0 before the request starts, the HTTP request will time out after timeout seconds have passed and the request is not completed yet. For small HTTP requests such as REST API usage, set to a value between 10.0 and 30.0 to prevent the application from getting stuck if the request fails to get a response in a timely manner. For file downloads, leave this to 0.0 to prevent the download from failing if it takes too much time.
Creates request on the underlying using a raw array of bytes for the request body. If there is no configuration errors, it tries to connect using and passes parameters onto .
Returns OK if request is successfully created. (Does not imply that the server has responded), ERR_UNCONFIGURED if not in the tree, ERR_BUSY if still processing previous request, ERR_INVALID_PARAMETER if given string is not a valid URL format, or ERR_CANT_CONNECT if not using thread and the cannot connect to host.
If the parameter is null, then the default value is Array.Empty<string>()
If the parameter is null, then the default value is Array.Empty<byte>()
Creates request on the underlying . If there is no configuration errors, it tries to connect using and passes parameters onto .
Returns OK if request is successfully created. (Does not imply that the server has responded), ERR_UNCONFIGURED if not in the tree, ERR_BUSY if still processing previous request, ERR_INVALID_PARAMETER if given string is not a valid URL format, or ERR_CANT_CONNECT if not using thread and the cannot connect to host.
Note: When method is , the payload sent via request_data might be ignored by the server or even cause the server to reject the request (check RFC 7231 section 4.3.1 for more details). As a workaround, you can send data as a query string in the URL. See String.http_escape for an example.
If the parameter is null, then the default value is Array.Empty<string>()
Cancels the current request.
Returns the current status of the underlying . See .
Returns the amount of bytes this HTTPRequest downloaded.
Returns the response body length.
Note: Some Web servers may not send a body length. In this case, the value returned will be -1. If using chunked transfer encoding, the body length will also be -1.
Sets the proxy server for HTTP requests.
The proxy server is unset if host is empty or port is -1.
Sets the proxy server for HTTPS requests.
The proxy server is unset if host is empty or port is -1.
The HashingContext class provides an interface for computing cryptographic hashes over multiple iterations. This is useful for example when computing hashes of big files (so you don't have to load them all in memory), network streams, and data streams in general (so you don't have to hold buffers).
The enum shows the supported hashing algorithms.
const CHUNK_SIZE = 1024
func hash_file(path):
var ctx = HashingContext.new()
var file = File.new()
# Start a SHA-256 context.
ctx.start(HashingContext.HASH_SHA256)
# Check that file exists.
if not file.file_exists(path):
return
# Open the file to hash.
file.open(path, File.READ)
# Update the context after reading each chunk.
while not file.eof_reached():
ctx.update(file.get_buffer(CHUNK_SIZE))
# Get the computed hash.
var res = ctx.finish()
# Print the result as hex string and array.
printt(res.hex_encode(), Array(res))
Hashing algorithm: MD5.
Hashing algorithm: SHA-1.
Hashing algorithm: SHA-256.
Starts a new hash computation of the given type (e.g. to start computation of a SHA-256).
Updates the computation with the given chunk of data.
Closes the current context, and return the computed hash.
Height map shape resource, which can be added to a or .
Number of vertices in the width of the height map. Changing this will resize the .
Number of vertices in the depth of the height map. Changing this will resize the .
Height map data, pool array must be of * size.
A HingeJoint normally uses the Z axis of body A as the hinge axis, another axis can be specified when adding it manually though. See also .
The speed with which the two bodies get pulled together when they move in different directions.
The maximum rotation. Only active if is true.
The minimum rotation. Only active if is true.
The speed with which the rotation across the axis perpendicular to the hinge gets corrected.
The lower this value, the more the rotation gets slowed down.
Target speed for the motor.
Maximum acceleration for the motor.
Represents the size of the enum.
If true, the hinges maximum and minimum rotation, defined by and has effects.
When activated, a motor turns the hinge.
Represents the size of the enum.
The speed with which the two bodies get pulled together when they move in different directions.
If true, the hinges maximum and minimum rotation, defined by and has effects.
The maximum rotation. Only active if is true.
The minimum rotation. Only active if is true.
The speed with which the rotation across the axis perpendicular to the hinge gets corrected.
The lower this value, the more the rotation gets slowed down.
When activated, a motor turns the hinge.
Target speed for the motor.
Maximum acceleration for the motor.
Sets the value of the specified parameter.
Returns the value of the specified parameter.
If true, enables the specified flag.
Returns the value of the specified flag.
IP contains support functions for the Internet Protocol (IP). TCP/IP support is in different classes (see and ). IP provides DNS hostname resolution support, both blocking and threaded.
Maximum number of concurrent DNS resolver queries allowed, is returned if exceeded.
Invalid ID constant. Returned if is exceeded.
DNS hostname resolver status: No status.
DNS hostname resolver status: Waiting.
DNS hostname resolver status: Done.
DNS hostname resolver status: Error.
Address type: None.
Address type: Internet protocol version 4 (IPv4).
Address type: Internet protocol version 6 (IPv6).
Address type: Any.
Returns a given hostname's IPv4 or IPv6 address when resolved (blocking-type method). The address type returned depends on the constant given as ip_type.
Resolves a given hostname in a blocking way. Addresses are returned as an of IPv4 or IPv6 depending on ip_type.
Creates a queue item to resolve a hostname to an IPv4 or IPv6 address depending on the constant given as ip_type. Returns the queue ID if successful, or on error.
Returns a queued hostname's status as a constant, given its queue id.
Returns a queued hostname's IP address, given its queue id. Returns an empty string on error or if resolution hasn't happened yet (see ).
Return resolved addresses, or an empty array if an error happened or resolution didn't happen yet (see ).
Removes a given item id from the queue. This should be used to free a queue after it has completed to enable more queries to happen.
Returns all the user's current IPv4 and IPv6 addresses as an array.
Returns all network adapters as an array.
Each adapter is a dictionary of the form:
{
"index": "1", # Interface index.
"name": "eth0", # Interface name.
"friendly": "Ethernet One", # A friendly name (might be empty).
"addresses": ["192.168.1.101"], # An array of IP addresses associated to this interface.
}
Removes all of a hostname's cached references. If no hostname is given, all cached IP addresses are removed.
Native image datatype. Contains image data which can be converted to an and provides commonly used image processing methods. The maximum width and height for an are and .
An cannot be assigned to a texture property of an object directly (such as ), and has to be converted manually to an first.
Note: The maximum image size is 16384×16384 pixels due to graphics hardware limitations. Larger images may fail to import.
The maximal width allowed for resources.
The maximal height allowed for resources.
Image does not have alpha.
Image stores alpha in a single bit.
Image uses alpha.
Source texture (before compression) is a regular texture. Default for all textures.
Source texture (before compression) is in sRGB space.
Source texture (before compression) is a normal texture (e.g. it can be compressed into two channels).
Source texture (before compression) is a .
Performs nearest-neighbor interpolation. If the image is resized, it will be pixelated.
Performs bilinear interpolation. If the image is resized, it will be blurry. This mode is faster than , but it results in lower quality.
Performs cubic interpolation. If the image is resized, it will be blurry. This mode often gives better results compared to , at the cost of being slower.
Performs bilinear separately on the two most-suited mipmap levels, then linearly interpolates between them.
It's slower than , but produces higher-quality results with far fewer aliasing artifacts.
If the image does not have mipmaps, they will be generated and used internally, but no mipmaps will be generated on the resulting image.
Note: If you intend to scale multiple copies of the original image, it's better to call ] on it in advance, to avoid wasting processing power in generating them again and again.
On the other hand, if the image already has mipmaps, they will be used, and a new set will be generated for the resulting image.
Performs Lanczos interpolation. This is the slowest image resizing mode, but it typically gives the best results, especially when downscalng images.
Use S3TC compression.
Use PVRTC2 compression.
Use PVRTC4 compression.
Use ETC compression.
Use ETC2 compression.
Texture format with a single 8-bit depth representing luminance.
OpenGL texture format with two values, luminance and alpha each stored with 8 bits.
OpenGL texture format RED with a single component and a bitdepth of 8.
Note: When using the GLES2 backend, this uses the alpha channel instead of the red channel for storage.
OpenGL texture format RG with two components and a bitdepth of 8 for each.
OpenGL texture format RGB with three components, each with a bitdepth of 8.
Note: When creating an , an sRGB to linear color space conversion is performed.
OpenGL texture format RGBA with four components, each with a bitdepth of 8.
Note: When creating an , an sRGB to linear color space conversion is performed.
OpenGL texture format RGBA with four components, each with a bitdepth of 4.
OpenGL texture format GL_RGB5_A1 where 5 bits of depth for each component of RGB and one bit for alpha.
OpenGL texture format GL_R32F where there's one component, a 32-bit floating-point value.
OpenGL texture format GL_RG32F where there are two components, each a 32-bit floating-point values.
OpenGL texture format GL_RGB32F where there are three components, each a 32-bit floating-point values.
OpenGL texture format GL_RGBA32F where there are four components, each a 32-bit floating-point values.
OpenGL texture format GL_R32F where there's one component, a 16-bit "half-precision" floating-point value.
OpenGL texture format GL_RG32F where there are two components, each a 16-bit "half-precision" floating-point value.
OpenGL texture format GL_RGB32F where there are three components, each a 16-bit "half-precision" floating-point value.
OpenGL texture format GL_RGBA32F where there are four components, each a 16-bit "half-precision" floating-point value.
A special OpenGL texture format where the three color components have 9 bits of precision and all three share a single 5-bit exponent.
The S3TC texture format that uses Block Compression 1, and is the smallest variation of S3TC, only providing 1 bit of alpha and color data being premultiplied with alpha.
Note: When creating an , an sRGB to linear color space conversion is performed.
The S3TC texture format that uses Block Compression 2, and color data is interpreted as not having been premultiplied by alpha. Well suited for images with sharp alpha transitions between translucent and opaque areas.
Note: When creating an , an sRGB to linear color space conversion is performed.
The S3TC texture format also known as Block Compression 3 or BC3 that contains 64 bits of alpha channel data followed by 64 bits of DXT1-encoded color data. Color data is not premultiplied by alpha, same as DXT3. DXT5 generally produces superior results for transparent gradients compared to DXT3.
Note: When creating an , an sRGB to linear color space conversion is performed.
Texture format that uses Red Green Texture Compression, normalizing the red channel data using the same compression algorithm that DXT5 uses for the alpha channel.
Texture format that uses Red Green Texture Compression, normalizing the red and green channel data using the same compression algorithm that DXT5 uses for the alpha channel.
Texture format that uses BPTC compression with unsigned normalized RGBA components.
Note: When creating an , an sRGB to linear color space conversion is performed.
Texture format that uses BPTC compression with signed floating-point RGB components.
Texture format that uses BPTC compression with unsigned floating-point RGB components.
Texture format used on PowerVR-supported mobile platforms, uses 2-bit color depth with no alpha. More information can be found here.
Note: When creating an , an sRGB to linear color space conversion is performed.
Same as PVRTC2, but with an alpha component.
Similar to PVRTC2, but with 4-bit color depth and no alpha.
Same as PVRTC4, but with an alpha component.
Ericsson Texture Compression format 1, also referred to as "ETC1", and is part of the OpenGL ES graphics standard. This format cannot store an alpha channel.
Ericsson Texture Compression format 2 (R11_EAC variant), which provides one channel of unsigned data.
Ericsson Texture Compression format 2 (SIGNED_R11_EAC variant), which provides one channel of signed data.
Ericsson Texture Compression format 2 (RG11_EAC variant), which provides two channels of unsigned data.
Ericsson Texture Compression format 2 (SIGNED_RG11_EAC variant), which provides two channels of signed data.
Ericsson Texture Compression format 2 (RGB8 variant), which is a follow-up of ETC1 and compresses RGB888 data.
Note: When creating an , an sRGB to linear color space conversion is performed.
Ericsson Texture Compression format 2 (RGBA8variant), which compresses RGBA8888 data with full alpha support.
Note: When creating an , an sRGB to linear color space conversion is performed.
Ericsson Texture Compression format 2 (RGB8_PUNCHTHROUGH_ALPHA1 variant), which compresses RGBA data to make alpha either fully transparent or fully opaque.
Note: When creating an , an sRGB to linear color space conversion is performed.
Represents the size of the enum.
Holds all the image's color data in a given format. See constants.
Returns the image's width.
Returns the image's height.
Returns the image's size (width and height).
Returns true if the image has generated mipmaps.
Returns the image's format. See constants.
Returns a copy of the image's raw data.
Converts the image's format. See constants.
Returns the offset where the image's mipmap with index mipmap is stored in the data dictionary.
Resizes the image to the nearest power of 2 for the width and height. If square is true then set width and height to be the same. New pixels are calculated using the interpolation mode defined via constants.
Resizes the image to the given width and height. New pixels are calculated using the interpolation mode defined via constants.
Shrinks the image by a factor of 2.
Stretches the image and enlarges it by a factor of 2. No interpolation is done.
Crops the image to the given width and height. If the specified size is larger than the current size, the extra area is filled with black pixels.
Flips the image horizontally.
Flips the image vertically.
Generates mipmaps for the image. Mipmaps are precalculated lower-resolution copies of the image that are automatically used if the image needs to be scaled down when rendered. They help improve image quality and performance when rendering. This method returns an error if the image is compressed, in a custom format, or if the image's width/height is 0.
Note: Mipmap generation is done on the CPU, is single-threaded and is always done on the main thread. This means generating mipmaps will result in noticeable stuttering during gameplay, even if is called from a .
Removes the image's mipmaps.
Creates an empty image of given size and format. See constants. If use_mipmaps is true then generate mipmaps for this image. See the .
Creates a new image of given size and format. See constants. Fills the image with the given raw data. If use_mipmaps is true then loads mipmaps for this image from data. See .
Returns true if the image has no data.
Loads an image from file path. See Supported image formats for a list of supported image formats and limitations.
Warning: This method should only be used in the editor or in cases when you need to load external images at run-time, such as images located at the user:// directory, and may not work in exported projects.
See also description for usage examples.
Saves the image as a PNG file to path.
Saves the image as an EXR file to path. If grayscale is true and the image has only one channel, it will be saved explicitly as monochrome rather than one red channel. This function will return ERR_UNAVAILABLE if Godot was compiled without the TinyEXR module.
Note: The TinyEXR module is disabled in non-editor builds, which means will return ERR_UNAVAILABLE when it is called from an exported project.
Returns if the image has data for alpha values. Returns if all the alpha values are stored in a single bit. Returns if no data for alpha values is found.
Returns true if all the image's pixels have an alpha value of 0. Returns false if any pixel has an alpha value higher than 0.
Compresses the image to use less memory. Can not directly access pixel data while the image is compressed. Returns error if the chosen compression mode is not available. See and constants.
Decompresses the image if it is compressed. Returns an error if decompress function is not available.
Returns true if the image is compressed.
Blends low-alpha pixels with nearby pixels.
Multiplies color values with alpha values. Resulting color values for a pixel are (color * alpha)/256.
Converts the raw data from the sRGB colorspace to a linear scale.
Converts the image's data to represent coordinates on a 3D plane. This is used when the image represents a normalmap. A normalmap can add lots of detail to a 3D surface without increasing the polygon count.
Converts a standard RGBE (Red Green Blue Exponent) image to an sRGB image.
Converts a bumpmap to a normalmap. A bumpmap provides a height offset per-pixel, while a normalmap provides a normal direction per pixel.
Copies src_rect from src image to this image at coordinates dst, clipped accordingly to both image bounds. This image and src image must have the same format. src_rect with not positive size is treated as empty.
Blits src_rect area from src image to this image at the coordinates given by dst, clipped accordingly to both image bounds. src pixel is copied onto dst if the corresponding mask pixel's alpha value is not 0. This image and src image must have the same format. src image and mask image must have the same size (width and height) but they can have different formats. src_rect with not positive size is treated as empty.
Alpha-blends src_rect from src image to this image at coordinates dest, clipped accordingly to both image bounds. This image and src image must have the same format. src_rect with not positive size is treated as empty.
Alpha-blends src_rect from src image to this image using mask image at coordinates dst, clipped accordingly to both image bounds. Alpha channels are required for both src and mask. dst pixels and src pixels will blend if the corresponding mask pixel's alpha value is not 0. This image and src image must have the same format. src image and mask image must have the same size (width and height) but they can have different formats. src_rect with not positive size is treated as empty.
Fills the image with color.
Fills rect with color.
Returns a enclosing the visible portion of the image, considering each pixel with a non-zero alpha channel as visible.
Returns a new image that is a copy of the image's area specified with rect.
Copies src image to this image.
Locks the data for reading and writing access. Sends an error to the console if the image is not locked when reading or writing a pixel.
Unlocks the data and prevents changes.
Returns the color of the pixel at src if the image is locked. If the image is unlocked, it always returns a with the value (0, 0, 0, 1.0). This is the same as , but with a Vector2 argument instead of two integer arguments.
Returns the color of the pixel at (x, y) if the image is locked. If the image is unlocked, it always returns a with the value (0, 0, 0, 1.0). This is the same as , but two integer arguments instead of a Vector2 argument.
Sets the of the pixel at (dst.x, dst.y) if the image is locked. Note that the dst values must be integers. Example:
var img = Image.new()
img.create(img_width, img_height, false, Image.FORMAT_RGBA8)
img.lock()
img.set_pixelv(Vector2(x, y), color) # Works
img.unlock()
img.set_pixelv(Vector2(x, y), color) # Does not have an effect
Sets the of the pixel at (x, y) if the image is locked. Example:
var img = Image.new()
img.create(img_width, img_height, false, Image.FORMAT_RGBA8)
img.lock()
img.set_pixel(x, y, color) # Works
img.unlock()
img.set_pixel(x, y, color) # Does not have an effect
Loads an image from the binary contents of a PNG file.
Loads an image from the binary contents of a JPEG file.
Loads an image from the binary contents of a WebP file.
Loads an image from the binary contents of a TGA file.
Loads an image from the binary contents of a BMP file.
Note: Godot's BMP module doesn't support 16-bit per pixel images. Only 1-bit, 4-bit, 8-bit, 24-bit, and 32-bit per pixel images are supported.
A based on an . For an image to be displayed, an has to be created from it using the method:
var texture = ImageTexture.new()
var image = Image.new()
image.load("res://icon.png")
texture.create_from_image(image)
$Sprite.texture = texture
This way, textures can be created at run-time by loading images both from within the editor and externally.
Warning: Prefer to load imported textures with @GDScript.load over loading them from within the filesystem dynamically with , as it may not work in exported projects:
var texture = load("res://icon.png")
$Sprite.texture = texture
This is because images have to be imported as first to be loaded with @GDScript.load. If you'd still like to load an image file just like any other , import it as an resource instead, and then load it normally using the @GDScript.load method.
But do note that the image data can still be retrieved from an imported texture as well using the method, which returns a copy of the data:
var texture = load("res://icon.png")
var image : Image = texture.get_data()
An is not meant to be operated from within the editor interface directly, and is mostly useful for rendering images on screen dynamically via code. If you need to generate images procedurally from within the editor, consider saving and importing images as custom texture resources implementing a new .
Note: The maximum texture size is 16384×16384 pixels due to graphics hardware limitations.
data is stored raw and unaltered.
data is compressed with a lossy algorithm. You can set the storage quality with .
data is compressed with a lossless algorithm.
The storage type (raw, lossy, or compressed).
The storage quality for .
Create a new with width and height.
format is a value from , flags is any combination of .
Initializes the texture by allocating and setting the data from an with flags from . An sRGB to linear color space conversion can take place, according to .
Returns the format of the texture, one of .
Loads an image from a file path and creates a texture from it.
Note: This method is deprecated and will be removed in Godot 4.0, use and instead.
Replaces the texture's data with a new .
Note: The texture has to be initialized first with the method before it can be updated. The new image dimensions, format, and mipmaps configuration should match the existing texture's image configuration, otherwise it has to be re-created with the method.
Use this method over if you need to update the texture frequently, which is faster than allocating additional memory for a new texture each time.
Resizes the texture to the specified dimensions.
Draws simple geometry from code. Uses a drawing mode similar to OpenGL 1.x.
See also , and for procedural geometry generation.
Note: ImmediateGeometry3D is best suited to small amounts of mesh data that change every frame. It will be slow when handling large amounts of mesh data. If mesh data doesn't change often, use , or instead.
Note: Godot uses clockwise winding order for front faces of triangle primitive modes.
Note: In case of missing points when handling large amounts of mesh data, try increasing its buffer size limit under .
Begin drawing (and optionally pass a texture override). When done call . For more information on how this works, search for glBegin() and glEnd() references.
For the type of primitive, see the enum.
The next vertex's normal.
The next vertex's tangent (and binormal facing).
The current drawing color.
The next vertex's UV.
The next vertex's second layer UV.
Adds a vertex in local coordinate space with the currently set color/uv/etc.
Simple helper to draw an UV sphere with given latitude, longitude and radius.
Ends a drawing context and displays the results.
Clears everything that was drawn using begin/end.
A singleton that deals with inputs. This includes key presses, mouse buttons and movement, joypads, and input actions. Actions and their events can be set in the Input Map tab in the Project > Project Settings, or with the class.
Makes the mouse cursor visible if it is hidden.
Makes the mouse cursor hidden if it is visible.
Captures the mouse. The mouse will be hidden and its position locked at the center of the screen.
Note: If you want to process the mouse's movement in this mode, you need to use .
Makes the mouse cursor visible but confines it to the game window.
Arrow cursor. Standard, default pointing cursor.
I-beam cursor. Usually used to show where the text cursor will appear when the mouse is clicked.
Pointing hand cursor. Usually used to indicate the pointer is over a link or other interactable item.
Cross cursor. Typically appears over regions in which a drawing operation can be performed or for selections.
Wait cursor. Indicates that the application is busy performing an operation. This cursor shape denotes that the application isn't usable during the operation (e.g. something is blocking its main thread).
Busy cursor. Indicates that the application is busy performing an operation. This cursor shape denotes that the application is still usable during the operation.
Drag cursor. Usually displayed when dragging something.
Can drop cursor. Usually displayed when dragging something to indicate that it can be dropped at the current position.
Forbidden cursor. Indicates that the current action is forbidden (for example, when dragging something) or that the control at a position is disabled.
Vertical resize mouse cursor. A double-headed vertical arrow. It tells the user they can resize the window or the panel vertically.
Horizontal resize mouse cursor. A double-headed horizontal arrow. It tells the user they can resize the window or the panel horizontally.
Window resize mouse cursor. The cursor is a double-headed arrow that goes from the bottom left to the top right. It tells the user they can resize the window or the panel both horizontally and vertically.
Window resize mouse cursor. The cursor is a double-headed arrow that goes from the top left to the bottom right, the opposite of . It tells the user they can resize the window or the panel both horizontally and vertically.
Move cursor. Indicates that something can be moved.
Vertical split mouse cursor. On Windows, it's the same as .
Horizontal split mouse cursor. On Windows, it's the same as .
Help cursor. Usually a question mark.
Controls the mouse mode. See for more information.
If true, similar input events sent by the operating system are accumulated. When input accumulation is enabled, all input events generated during a frame will be merged and emitted when the frame is done rendering. Therefore, this limits the number of input method calls per second to the rendering FPS.
Input accumulation can be disabled to get slightly more precise/reactive input at the cost of increased CPU usage. In applications where drawing freehand lines is required, input accumulation should generally be disabled while the user is drawing the line to get results that closely follow the actual input.
Note: Input accumulation is enabled by default. It is recommended to keep it enabled for games which don't require very reactive input, as this will decrease CPU usage.
Returns true if you are pressing the key in the current keyboard layout. You can pass a constant.
is only recommended over in non-game applications. This ensures that shortcut keys behave as expected depending on the user's keyboard layout, as keyboard shortcuts are generally dependent on the keyboard layout in non-game applications. If in doubt, use .
Note: Due to keyboard ghosting, may return false even if one of the action's keys is pressed. See Input examples in the documentation for more information.
Returns true if you are pressing the key in the physical location on the 101/102-key US QWERTY keyboard. You can pass a constant.
is recommended over for in-game actions, as it will make W/A/S/D layouts work regardless of the user's keyboard layout. will also ensure that the top row number keys work on any keyboard layout. If in doubt, use .
Note: Due to keyboard ghosting, may return false even if one of the action's keys is pressed. See Input examples in the documentation for more information.
Returns true if you are pressing the mouse button specified with .
Returns true if you are pressing the joypad button (see ).
Returns true if you are pressing the action event. Note that if an action has multiple buttons assigned and more than one of them is pressed, releasing one button will release the action, even if some other button assigned to this action is still pressed.
If exact is false, it ignores additional input modifiers for and events, and the direction for events.
Note: Due to keyboard ghosting, may return false even if one of the action's keys is pressed. See Input examples in the documentation for more information.
Returns true when the user starts pressing the action event, meaning it's true only on the frame that the user pressed down the button.
This is useful for code that needs to run only once when an action is pressed, instead of every frame while it's pressed.
If exact is false, it ignores additional input modifiers for and events, and the direction for events.
Note: Due to keyboard ghosting, may return false even if one of the action's keys is pressed. See Input examples in the documentation for more information.
Returns true when the user stops pressing the action event, meaning it's true only on the frame that the user released the button.
If exact is false, it ignores additional input modifiers for and events, and the direction for events.
Returns a value between 0 and 1 representing the intensity of the given action. In a joypad, for example, the further away the axis (analog sticks or L2, R2 triggers) is from the dead zone, the closer the value will be to 1. If the action is mapped to a control that has no axis as the keyboard, the value returned will be 0 or 1.
If exact is false, it ignores additional input modifiers for and events, and the direction for events.
Returns a value between 0 and 1 representing the raw intensity of the given action, ignoring the action's deadzone. In most cases, you should use instead.
If exact is false, it ignores additional input modifiers for and events, and the direction for events.
Get axis input by specifying two actions, one negative and one positive.
This is a shorthand for writing Input.get_action_strength("positive_action") - Input.get_action_strength("negative_action").
Gets an input vector by specifying four actions for the positive and negative X and Y axes.
This method is useful when getting vector input, such as from a joystick, directional pad, arrows, or WASD. The vector has its length limited to 1 and has a circular deadzone, which is useful for using vector input as movement.
By default, the deadzone is automatically calculated from the average of the action deadzones. However, you can override the deadzone to be whatever you want (on the range of 0 to 1).
Adds a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices.
Removes all mappings from the internal database that match the given GUID.
Notifies the singleton that a connection has changed, to update the state for the device index.
This is used internally and should not have to be called from user scripts. See joy_connection_changed for the signal emitted when this is triggered internally.
Returns true if the system knows the specified device. This means that it sets all button and axis indices exactly as defined in . Unknown joypads are not expected to match these constants, but you can still retrieve events from them.
Returns the current value of the joypad axis at given index (see ).
Returns the name of the joypad at the specified device index.
Returns a SDL2-compatible device GUID on platforms that use gamepad remapping. Returns "Default Gamepad" otherwise.
Returns an containing the device IDs of all currently connected joypads.
Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor.
Returns the duration of the current vibration effect in seconds.
Receives a gamepad button from and returns its equivalent name as a string.
Returns the index of the provided button name.
Receives a axis and returns its equivalent name as a string.
Returns the index of the provided axis name.
Starts to vibrate the joypad. Joypads usually come with two rumble motors, a strong and a weak one. weak_magnitude is the strength of the weak motor (between 0 and 1) and strong_magnitude is the strength of the strong motor (between 0 and 1). duration is the duration of the effect in seconds (a duration of 0 will try to play the vibration indefinitely).
Note: Not every hardware is compatible with long effect durations; it is recommended to restart an effect if it has to be played for more than a few seconds.
Stops the vibration of the joypad.
Vibrate handheld devices.
Note: This method is implemented on Android, iOS, and HTML5.
Note: For Android, it requires enabling the VIBRATE permission in the export preset.
Note: For iOS, specifying the duration is supported in iOS 13 and later.
Note: Some web browsers such as Safari and Firefox for Android do not support this method.
Returns the gravity of the device's accelerometer sensor, if the device has one. Otherwise, the method returns Vector3.ZERO.
Note: This method only works on Android and iOS. On other platforms, it always returns Vector3.ZERO. On Android the unit of measurement for each axis is m/s² while on iOS it's a multiple of the Earth's gravitational acceleration g (~9.81 m/s²).
Returns the acceleration of the device's accelerometer sensor, if the device has one. Otherwise, the method returns Vector3.ZERO.
Note this method returns an empty when running from the editor even when your device has an accelerometer. You must export your project to a supported device to read values from the accelerometer.
Note: This method only works on iOS, Android, and UWP. On other platforms, it always returns Vector3.ZERO. On Android the unit of measurement for each axis is m/s² while on iOS and UWP it's a multiple of the Earth's gravitational acceleration g (~9.81 m/s²).
Returns the magnetic field strength in micro-Tesla for all axes of the device's magnetometer sensor, if the device has one. Otherwise, the method returns Vector3.ZERO.
Note: This method only works on Android, iOS and UWP. On other platforms, it always returns Vector3.ZERO.
Returns the rotation rate in rad/s around a device's X, Y, and Z axes of the gyroscope sensor, if the device has one. Otherwise, the method returns Vector3.ZERO.
Note: This method only works on Android and iOS. On other platforms, it always returns Vector3.ZERO.
Sets the gravity value of the accelerometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
Note: This value can be immediately overwritten by the hardware sensor value on Android and iOS.
Sets the acceleration value of the accelerometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
Note: This value can be immediately overwritten by the hardware sensor value on Android and iOS.
Sets the value of the magnetic field of the magnetometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
Note: This value can be immediately overwritten by the hardware sensor value on Android and iOS.
Sets the value of the rotation rate of the gyroscope sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
Note: This value can be immediately overwritten by the hardware sensor value on Android and iOS.
Returns the mouse speed for the last time the cursor was moved, and this until the next frame where the mouse moves. This means that even if the mouse is not moving, this function will still return the value of the last motion.
Returns mouse buttons as a bitmask. If multiple mouse buttons are pressed at the same time, the bits are added together.
Sets the mouse position to the specified vector, provided in pixels and relative to an origin at the upper left corner of the game window.
Mouse position is clipped to the limits of the screen resolution, or to the limits of the game window if is set to .
This will simulate pressing the specified action.
The strength can be used for non-boolean actions, it's ranged between 0 and 1 representing the intensity of the given action.
Note: This method will not cause any calls. It is intended to be used with and . If you want to simulate _input, use instead.
If the specified action is already pressed, this will release it.
Sets the default cursor shape to be used in the viewport instead of .
Note: If you want to change the default cursor shape for 's nodes, use instead.
Note: This method generates an to update cursor immediately.
Returns the currently assigned cursor shape (see ).
Sets a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified. Passing null to the image parameter resets to the system cursor. See for the list of shapes.
image's size must be lower than 256×256.
hotspot must be within image's size.
Note: s aren't supported as custom mouse cursors. If using an , only the first frame will be displayed.
Note: Only images imported with the Lossless, Lossy or Uncompressed compression modes are supported. The Video RAM compression mode can't be used for custom cursors.
If the parameter is null, then the default value is new Vector2(0, 0)
Feeds an to the game. Can be used to artificially trigger input events from code. Also generates calls.
Example:
var a = InputEventAction.new()
a.action = "ui_cancel"
a.pressed = true
Input.parse_input_event(a)
Sends all input events which are in the current buffer to the game loop. These events may have been buffered as a result of accumulated input () or agile input flushing ().
The engine will already do this itself at key execution points (at least once per frame). However, this can be useful in advanced cases where you want precise control over the timing of event handling.
Base class of all sort of input event. See .
The event's device ID.
Note: This device ID will always be -1 for emulated mouse input from a touchscreen. This can be used to distinguish emulated mouse input from physical mouse input.
Returns true if this input event matches a pre-defined action of any type.
If exact_match is false, it ignores additional input modifiers for and events, and the direction for events.
Returns true if the given action is being pressed (and is not an echo event for events, unless allow_echo is true). Not relevant for events of type or .
If exact_match is false, it ignores additional input modifiers for and events, and the direction for events.
Note: Due to keyboard ghosting, may return false even if one of the action's keys is pressed. See Input examples in the documentation for more information.
Returns true if the given action is released (i.e. not pressed). Not relevant for events of type or .
If exact_match is false, it ignores additional input modifiers for and events, and the direction for events.
Returns a value between 0.0 and 1.0 depending on the given actions' state. Useful for getting the value of events of type .
If exact_match is false, it ignores additional input modifiers for and events, and the direction for events.
Returns true if this input event is pressed. Not relevant for events of type or .
Note: Due to keyboard ghosting, may return false even if one of the action's keys is pressed. See Input examples in the documentation for more information.
Returns true if this input event is an echo event (only for events of type ).
Returns a representation of the event.
Returns true if the specified event matches this event. Only valid for action events i.e key (), button ( or ), axis or action () events.
If exact_match is false, it ignores additional input modifiers for and events, and the direction for events.
Returns true if this input event's type is one that can be assigned to an input action.
Returns true if the given input event and this input event can be added together (only for events of type ).
The given input event's position, global position and speed will be copied. The resulting relative is a sum of both events. Both events' modifiers have to be identical.
Returns a copy of the given input event which has been offset by local_ofs and transformed by xform. Relevant for events of type , , , , and .
If the parameter is null, then the default value is new Vector2(0, 0)
Contains a generic action which can be targeted from several types of inputs. Actions can be created from the Input Map tab in the Project > Project Settings menu. See .
The action's name. Actions are accessed via this .
If true, the action's state is pressed. If false, the action's state is released.
The action's strength between 0 and 1. This value is considered as equal to 0 if pressed is false. The event strength allows faking analog joypad motion events, by specifying how strongly the joypad axis is bent or pressed.
The local gesture position relative to the . If used in , the position is relative to the current that received this gesture.
Input event type for gamepad buttons. For gamepad analog sticks and joysticks, see .
Button identifier. One of the button constants.
Represents the pressure the user puts on the button with their finger, if the controller supports it. Ranges from 0 to 1.
If true, the button's state is pressed. If false, the button's state is released.
Stores information about joystick motions. One represents one axis at a time.
Axis identifier. Use one of the axis constants.
Current position of the joystick on the given axis. The value ranges from -1.0 to 1.0. A value of 0 means the axis is in its resting position.
Stores key presses on the keyboard. Supports key presses, key releases and events.
If true, the key's state is pressed. If false, the key's state is released.
The key scancode, which corresponds to one of the constants. Represent key in the current keyboard layout.
To get a human-readable representation of the , use OS.get_scancode_string(event.scancode) where event is the .
Key physical scancode, which corresponds to one of the constants. Represent the physical location of a key on the 101/102-key US QWERTY keyboard.
To get a human-readable representation of the , use OS.get_scancode_string(event.physical_scancode) where event is the .
The key Unicode identifier (when relevant). Unicode identifiers for the composite characters and complex scripts may not be available unless IME input mode is active. See for more information.
If true, the key was already pressed before this event. It means the user is holding the key down.
Returns the scancode combined with modifier keys such as Shift or Alt. See also .
To get a human-readable representation of the with modifiers, use OS.get_scancode_string(event.get_scancode_with_modifiers()) where event is the .
Returns the physical scancode combined with modifier keys such as Shift or Alt. See also .
To get a human-readable representation of the with modifiers, use OS.get_scancode_string(event.get_physical_scancode_with_modifiers()) where event is the .
InputEventMIDI allows receiving input events from MIDI devices such as a piano. MIDI stands for Musical Instrument Digital Interface.
MIDI signals can be sent over a 5-pin MIDI connector or over USB, if your device supports both be sure to check the settings in the device to see which output it's using.
To receive input events from MIDI devices, you need to call . You can check which devices are detected using .
Note that Godot does not currently support MIDI output, so there is no way to emit MIDI signals from Godot. Only MIDI input works.
The MIDI channel of this input event. There are 16 channels, so this value ranges from 0 to 15. MIDI channel 9 is reserved for the use with percussion instruments, the rest of the channels are for non-percussion instruments.
Returns a value indicating the type of message for this MIDI signal. This is a member of the enum.
For MIDI messages between 0x80 and 0xEF, only the left half of the bits are returned as this value, as the other part is the channel (ex: 0x94 becomes 0x9). For MIDI messages from 0xF0 to 0xFF, the value is returned as-is.
Notes will return MIDI_MESSAGE_NOTE_ON when activated, but they might not always return MIDI_MESSAGE_NOTE_OFF when deactivated, therefore your code should treat the input as stopped if some period of time has passed.
For more information, see the MIDI message status byte list chart linked above.
The pitch index number of this MIDI signal. This value ranges from 0 to 127. On a piano, middle C is 60, and A440 is 69, see the "MIDI note" column of the piano key frequency chart on Wikipedia for more information.
The velocity of the MIDI signal. This value ranges from 0 to 127. For a piano, this corresponds to how quickly the key was pressed, and is rarely above about 110 in practice.
The instrument of this input event. This value ranges from 0 to 127. Refer to the instrument list on the General MIDI wikipedia article to see a list of instruments, except that this value is 0-index, so subtract one from every number on that chart. A standard piano will have an instrument number of 0.
The pressure of the MIDI signal. This value ranges from 0 to 127. For many devices, this value is always zero.
If the message is MIDI_MESSAGE_CONTROL_CHANGE, this indicates the controller number, otherwise this is zero. Controllers include devices such as pedals and levers.
If the message is MIDI_MESSAGE_CONTROL_CHANGE, this indicates the controller value, otherwise this is zero. Controllers include devices such as pedals and levers.
Stores general mouse events information.
The mouse button mask identifier, one of or a bitwise combination of the button masks.
When received in or , returns the mouse's position in the this is in using the coordinate system of this .
When received in , returns the mouse's position in the using the local coordinate system of the .
When received in or , returns the mouse's position in the root using the coordinate system of the root .
When received in , returns the mouse's position in the that the is in using the coordinate system of the .
Contains mouse click information. See .
The amount (or delta) of the event. When used for high-precision scroll events, this indicates the scroll amount (vertical or horizontal). This is only supported on some platforms; the reported sensitivity varies depending on the platform. May be 0 if not supported.
The mouse button identifier, one of the button or button wheel constants.
If true, the mouse button's state is pressed. If false, the mouse button's state is released.
If true, the mouse button's state is a double-click.
Contains mouse and pen motion information. Supports relative, absolute positions and speed. See .
Note: The behavior of this event is affected by the value of . When set to true (default), mouse/pen motion events received from the OS will be merged to emit an accumulated event only once per frame rendered at most. When set to false, the events will be emitted as received, which means that they can be emitted multiple times per frame rendered, allowing for precise input reporting at the expense of CPU usage.
Note: If you use InputEventMouseMotion to draw lines, consider implementing Bresenham's line algorithm as well to avoid visible gaps in lines if the user is moving the mouse quickly.
Represents the angles of tilt of the pen. Positive X-coordinate value indicates a tilt to the right. Positive Y-coordinate value indicates a tilt toward the user. Ranges from -1.0 to 1.0 for both axes.
Represents the pressure the user puts on the pen. Ranges from 0.0 to 1.0.
Returns true when using the eraser end of a stylus pen.
Note: This property is implemented on Linux, macOS and Windows.
The mouse position relative to the previous position (position at the last frame).
Note: Since is only emitted when the mouse moves, the last event won't have a relative position of Vector2(0, 0) when the user stops moving the mouse.
The mouse speed in pixels per second.
Contains screen drag information. See .
The drag event index in the case of a multi-drag event.
The drag position.
The drag position relative to the previous position (position at the last frame).
The drag speed.
Stores multi-touch press/release information. Supports touch press, touch release and for multi-touch count and order.
The touch index in the case of a multi-touch event. One index = one finger.
The touch position.
If true, the touch's state is pressed. If false, the touch's state is released.
Contains keys events information with modifiers support like Shift or Alt. See .
State of the Alt modifier.
State of the Shift modifier.
State of the Ctrl modifier.
State of the Meta modifier.
State of the Command modifier.
Manages all which can be created/modified from the project settings menu Project > Project Settings > Input Map or in code with and . See .
Returns true if the has a registered action with the given name.
Returns an array of all actions in the .
Adds an empty action to the with a configurable deadzone.
An can then be added to this action with .
Removes an action from the .
Sets a deadzone value for the action.
Returns a deadzone value for the action.
Adds an to an action. This will trigger the action.
Returns true if the action has the given associated with it.
Removes an from an action.
Removes all events from an action.
Returns an array of s associated with a given action.
Note: When used in the editor (e.g. a tool script or ), this method will return events for the editor action. If you want to access your project's input binds from the editor, read the input/* settings from .
Returns true if the given event is part of an existing action. This method ignores keyboard modifiers if the given is not pressed (for proper release detection). See if you don't want this behavior.
If exact_match is false, it ignores additional input modifiers for and events, and the direction for events.
Clears all in the and load it anew from .
Turning on the option Load As Placeholder for an instanced scene in the editor causes it to be replaced by an InstancePlaceholder when running the game. This makes it possible to delay actually loading the scene until calling . This is useful to avoid loading large scenes all at once by loading parts of it selectively.
The InstancePlaceholder does not have a transform. This causes any child nodes to be positioned relatively to the Viewport from point (0,0), rather than their parent as displayed in the editor. Replacing the placeholder with a scene with a transform will transform children relatively to their parent again.
Returns the list of properties that will be applied to the node when is called.
If with_order is true, a key named .order (note the leading period) is added to the dictionary. This .order key is an of property names specifying the order in which properties will be applied (with index 0 being the first).
Call this method to actually load in the node. The created node will be placed as a sibling above the in the scene tree. The 's reference is also returned for convenience.
Note: is not thread-safe. Use if calling from a thread.
Replaces this placeholder by the scene handed as an argument, or the original scene if no argument is given. As for all resources, the scene is loaded only if it's not loaded already. By manually loading the scene beforehand, delays caused by this function can be avoided.
Gets the path to the resource file that is loaded by default when calling . Not thread-safe. Use if calling from a thread.
Deprecated (will be removed in Godot 4.0). InterpolatedCamera is a which smoothly moves to match a target node's position and rotation.
If it is not or does not have a valid target set, InterpolatedCamera acts like a normal Camera.
The camera updates with the _physics_process callback.
The camera updates with the _process callback.
The target's .
How quickly the camera moves toward its target. Higher values will result in tighter camera motion.
If true, and a target is set, the camera will move automatically.
The camera's process callback. See .
Sets the node to move toward and orient with.
is used to make delays in a tweening sequence. See for more usage information.
Note: is the only correct way to create . Any created manually will not function correctly.
This control provides a selectable list of items that may be in a single (or multiple columns) with option of text, icons, or both text and icon. Tooltips are supported and may be different for every item in the list.
Selectable items in the list may be selected or deselected and multiple selection may be enabled. Selection with right mouse button may also be enabled to allow use of popup context menus. Items may also be "activated" by double-clicking them or by pressing Enter.
Item text only supports single-line strings, newline characters (e.g. \n) in the string won't produce a newline. Text wrapping is enabled in mode, but column's width is adjusted to fully fit its content by default. You need to set greater than zero to wrap the text.
Incremental search: Like and , supports searching within the list while the control is focused. Press a key that matches the first letter of an item's name to select the first item starting with the given letter. After that point, there are two ways to perform incremental search: 1) Press the same key again before the timeout duration to select the next item starting with the same letter. 2) Press letter keys that match the rest of the word before the timeout duration to match to select the item in question directly. Both of these actions will be reset to the beginning of the list if the timeout duration has passed since the last keystroke was registered. You can adjust the timeout duration by changing .
Only allow selecting a single item.
Allows selecting multiple items by holding Ctrl or Shift.
Icon is drawn above the text.
Icon is drawn to the left of the text.
Allows single or multiple item selection. See the constants.
If true, the currently selected item can be selected again.
If true, right mouse button click can select items.
Maximum lines of text allowed in each item. Space will be reserved even when there is not enough lines of text to display.
Note: This property takes effect only when is . To make the text wrap, should be greater than zero.
If true, the control will automatically resize the height to fit its content.
Maximum columns the list will have.
If greater than zero, the content will be split among the specified columns.
A value of zero means unlimited columns, i.e. all items will be put in the same row.
Whether all columns will have the same width.
If true, the width is equal to the largest column width of all columns.
The width all columns will be adjusted to.
A value of zero disables the adjustment, each item will have a width equal to the width of its content and the columns will have an uneven width.
The icon position, whether above or to the left of the text. See the constants.
The scale of icon applied after and transposing takes effect.
The size all icons will be adjusted to.
If either X or Y component is not greater than zero, icon size won't be affected.
Adds an item to the item list with specified text. Specify an icon, or use null as the icon for a list item with no icon.
If selectable is true, the list item will be selectable.
Adds an item to the item list with no text, only an icon.
Sets text of the item associated with the specified index.
Returns the text associated with the specified index.
Sets (or replaces) the icon's associated with the specified index.
Returns the icon associated with the specified index.
Sets whether the item icon will be drawn transposed.
Returns true if the item icon will be drawn transposed, i.e. the X and Y axes are swapped.
Sets the region of item's icon used. The whole icon will be used if the region has no area.
Returns the region of item's icon used. The whole icon will be used if the region has no area.
Sets a modulating of the item associated with the specified index.
Returns a modulating item's icon at the specified index.
Allows or disallows selection of the item associated with the specified index.
Returns true if the item at the specified index is selectable.
Disables (or enables) the item at the specified index.
Disabled items cannot be selected and do not trigger activation signals (when double-clicking or pressing Enter).
Returns true if the item at the specified index is disabled.
Sets a value (of any type) to be stored with the item associated with the specified index.
Returns the metadata value of the specified index.
Sets the background color of the item specified by idx index to the specified .
Returns the custom background color of the item specified by idx index.
Sets the foreground color of the item specified by idx index to the specified .
Returns the custom foreground color of the item specified by idx index.
Sets whether the tooltip hint is enabled for specified item index.
Returns true if the tooltip is enabled for specified item index.
Sets the tooltip hint for the item associated with the specified index.
Returns the tooltip hint associated with the specified index.
Select the item at the specified index.
Note: This method does not trigger the item selection signal.
Ensures the item associated with the specified index is not selected.
Ensures there are no items selected.
Returns true if the item at the specified index is currently selected.
Returns an array with the indexes of the selected items.
Moves item from index from_idx to to_idx.
Returns the number of items currently in the list.
Removes the item specified by idx index from the list.
Removes all items from the list.
Sorts items in the list by their text.
Returns true if one or more items are selected.
Returns the item index at the given position.
When there is no item at that point, -1 will be returned if exact is true, and the closest item index will be returned otherwise.
Ensure current selection is visible, adjusting the scroll position as necessary.
Returns the vertical scrollbar.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
The JNISingleton is implemented only in the Android export. It's used to call methods and connect signals from an Android plugin written in Java or Kotlin. Methods and signals can be called and connected to the JNISingleton as if it is a Node. See Java Native Interface - Wikipedia for more information.
Returned by , contains the decoded JSON or error information if the JSON source wasn't successfully parsed. You can check if the JSON source was successfully parsed with if json_result.error == OK.
The error type if the JSON source was not successfully parsed. See the constants.
The error message if the JSON source was not successfully parsed. See the constants.
The line number where the error occurred if the JSON source was not successfully parsed.
A Variant containing the parsed JSON. Use @GDScript.typeof or the is keyword to check if it is what you expect. For example, if the JSON source starts with curly braces ({}), a will be returned. If the JSON source starts with brackets ([]), an will be returned.
Note: The JSON specification does not define integer or float types, but only a number type. Therefore, parsing a JSON text will convert all numerical values to types.
Note: JSON objects do not preserve key order like Godot dictionaries, thus, you should not rely on keys being in a certain order if a dictionary is constructed from JSON. In contrast, JSON arrays retain the order of their elements:
var p = JSON.parse('["hello", "world", "!"]')
if typeof(p.result) == TYPE_ARRAY:
print(p.result[0]) # Prints "hello"
else:
push_error("Unexpected results.")
JSON-RPC is a standard which wraps a method call in a object. The object has a particular structure and identifies which method is called, the parameters to that function, and carries an ID to keep track of responses. This class implements that standard on top of ; you will have to convert between a and with other functions.
A method call was requested but no function of that name existed in the JSONRPC subclass.
Given a Dictionary which takes the form of a JSON-RPC request: unpack the request and run it. Methods are resolved by looking at the field called "method" and looking for an equivalently named function in the JSONRPC object. If one is found that method is called.
To add new supported methods extend the JSONRPC class and call on your subclass.
action: The action to be run, as a Dictionary in the form of a JSON-RPC request or notification.
Returns a dictionary in the form of a JSON-RPC request. Requests are sent to a server with the expectation of a response. The ID field is used for the server to specify which exact request it is responding to.
- method: Name of the method being called.
- params: An array or dictionary of parameters being passed to the method.
- id: Uniquely identifies this request. The server is expected to send a response with the same ID.
When a server has received and processed a request, it is expected to send a response. If you did not want a response then you need to have sent a Notification instead.
- result: The return value of the function which was called.
- id: The ID of the request this response is targeted to.
Returns a dictionary in the form of a JSON-RPC notification. Notifications are one-shot messages which do not expect a response.
- method: Name of the method being called.
- params: An array or dictionary of parameters being passed to the method.
Creates a response which indicates a previous reply has failed in some way.
- code: The error code corresponding to what kind of error this is. See the constants.
- message: A custom message about this error.
- id: The request this error is a response to.
The JavaScript singleton is implemented only in the HTML5 export. It's used to access the browser's JavaScript context. This allows interaction with embedding pages or calling third-party JavaScript APIs.
Note: This singleton can be disabled at build-time to improve security. By default, the JavaScript singleton is enabled. Official export templates also have the JavaScript singleton enabled. See Compiling for the Web in the documentation for more information.
Execute the string code as JavaScript code within the browser window. This is a call to the actual global JavaScript function eval().
If use_global_execution_context is true, the code will be evaluated in the global execution context. Otherwise, it is evaluated in the execution context of a function within the engine's runtime environment.
Returns an interface to a JavaScript object that can be used by scripts. The interface must be a valid property of the JavaScript window. The callback must accept a single argument, which will contain the JavaScript arguments. See for usage.
Creates a reference to a script function that can be used as a callback by JavaScript. The reference must be kept until the callback happens, or it won't be called at all. See for usage.
Creates a new JavaScript object using the new constructor. The object must a valid property of the JavaScript window. See for usage.
Prompts the user to download a file containing the specified buffer. The file will have the given name and mime type.
Note: The browser may override the MIME type provided based on the file name's extension.
Note: Browsers might block the download if is not being called from a user interaction (e.g. button click).
Note: Browsers might ask the user for permission or block the download if multiple download requests are made in a quick succession.
Returns true if a new version of the progressive web app is waiting to be activated.
Note: Only relevant when exported as a Progressive Web App.
Performs the live update of the progressive web app. Forcing the new version to be installed and the page to be reloaded.
Note: Your application will be reloaded in all browser tabs.
Note: Only relevant when exported as a Progressive Web App and returns true.
JavaScriptObject is used to interact with JavaScript objects retrieved or created via , , or .
Example:
extends Node
var _my_js_callback = JavaScript.create_callback(self, "myCallback") # This reference must be kept
var console = JavaScript.get_interface("console")
func _init():
var buf = JavaScript.create_object("ArrayBuffer", 10) # new ArrayBuffer(10)
print(buf) # prints [JavaScriptObject:OBJECT_ID]
var uint8arr = JavaScript.create_object("Uint8Array", buf) # new Uint8Array(buf)
uint8arr[1] = 255
prints(uint8arr[1], uint8arr.byteLength) # prints 255 10
console.log(uint8arr) # prints in browser console "Uint8Array(10) [ 0, 255, 0, 0, 0, 0, 0, 0, 0, 0 ]"
# Equivalent of JavaScript: Array.from(uint8arr).forEach(myCallback)
JavaScript.get_interface("Array").from(uint8arr).forEach(_my_js_callback)
func myCallback(args):
# Will be called with the parameters passed to the "forEach" callback
# [0, 0, [JavaScriptObject:1173]]
# [255, 1, [JavaScriptObject:1173]]
# ...
# [0, 9, [JavaScriptObject:1180]]
print(args)
Note: Only available in the HTML5 platform.
Joints are used to bind together two physics bodies. They have a solver priority and can define if the bodies of the two attached nodes should be able to collide with each other.
The node attached to the first side (A) of the joint.
The node attached to the second side (B) of the joint.
The priority used to define which solver is executed first for multiple joints. The lower the value, the higher the priority.
If true, the two bodies of the nodes are not able to collide with each other.
Base node for all joint constraints in 2D physics. Joints take 2 bodies and apply a custom constraint.
The first body attached to the joint. Must derive from .
The second body attached to the joint. Must derive from .
When and move in different directions the bias controls how fast the joint pulls them back to their original position. The lower the bias the more the two bodies can pull on the joint.
If true, and can not collide.
Kinematic bodies are special types of bodies that are meant to be user-controlled. They are not affected by physics at all; to other types of bodies, such as a character or a rigid body, these are the same as a static body. However, they have two main uses:
Simulated motion: When these bodies are moved manually, either from code or from an (with set to "physics"), the physics will automatically compute an estimate of their linear and angular velocity. This makes them very useful for moving platforms or other AnimationPlayer-controlled objects (like a door, a bridge that opens, etc).
Kinematic characters: KinematicBody also has an API for moving objects (the and methods) while performing collision tests. This makes them really useful to implement characters that collide against a world, but don't require advanced physics.
Add the last platform velocity when you leave a moving platform.
Add the last platform velocity when you leave a moving platform, but any downward motion is ignored. It's useful to keep full jump height even when the platform is moving down.
Do nothing when leaving a platform.
Lock the body's X axis movement.
Lock the body's Y axis movement.
Lock the body's Z axis movement.
Lock the body's X axis movement. Deprecated alias for .
Lock the body's Y axis movement. Deprecated alias for .
Lock the body's Z axis movement. Deprecated alias for .
Extra margin used for collision recovery in motion functions (see , , ).
If the body is at least this close to another body, it will consider them to be colliding and will be pushed away before performing the actual motion.
A higher value means it's more flexible for detecting collision, which helps with consistently detecting walls and floors.
A lower value forces the collision algorithm to use more exact detection, so it can be used in cases that specifically require precision, e.g at very low scale to avoid visible jittering, or for stability with a stack of kinematic bodies.
If true, the body's movement will be synchronized to the physics frame. This is useful when animating movement via , for example on moving platforms. Do not use together with or functions.
Sets the behavior to apply when you leave a moving platform. By default, to be physically accurate, when you leave the last platform velocity is applied. See constants for available behavior.
Moves the body along the vector rel_vec. The body will stop if it collides. Returns a , which contains information about the collision when stopped, or when touching another body along the motion.
If test_only is true, the body does not move but the would-be collision information is given.
Moves the body along a vector. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a or , it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes.
This method should be used in (or in a method called by ), as it uses the physics step's delta value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
linear_velocity is the velocity vector (typically meters per second). Unlike in , you should not multiply it by delta — the physics engine handles applying the velocity.
up_direction is the up direction, used to determine what is a wall and what is a floor or a ceiling. If set to the default value of Vector3(0, 0, 0), everything is considered a wall.
If stop_on_slope is true, body will not slide on slopes when you include gravity in linear_velocity and the body is standing still.
If the body collides, it will change direction a maximum of max_slides times before it stops.
floor_max_angle is the maximum angle (in radians) where a slope is still considered a floor (or a ceiling), rather than a wall. The default value equals 45 degrees.
If infinite_inertia is true, body will be able to push nodes, but it won't also detect any collisions with them. If false, it will interact with nodes like with .
Returns the linear_velocity vector, rotated and/or scaled if a slide collision occurred. To get detailed information about collisions that occurred, use .
When the body touches a moving platform, the platform's velocity is automatically added to the body motion. If a collision occurs due to the platform's motion, it will always be first in the slide collisions.
If the parameter is null, then the default value is new Vector3(0, 0, 0)
Moves the body while keeping it attached to slopes. Similar to .
As long as the snap vector is in contact with the ground, the body will remain attached to the surface. This means you must disable snap in order to jump, for example. You can do this by setting snap to (0, 0, 0) or by using instead.
If the parameter is null, then the default value is new Vector3(0, 0, 0)
Checks for collisions without moving the body. Virtually sets the node's position, scale and rotation to that of the given , then tries to move the body along the vector rel_vec. Returns true if a collision would stop the body from moving along the whole path.
Use instead for detecting collision with touching bodies.
Returns true if the body collided with the floor on the last call of or . Otherwise, returns false.
Returns true if the body collided with the ceiling on the last call of or . Otherwise, returns false.
Returns true if the body collided with a wall on the last call of or . Otherwise, returns false.
Returns the surface normal of the floor at the last collision point. Only valid after calling or and when returns true.
Returns the floor's collision angle at the last collision point according to up_direction, which is Vector3.UP by default. This value is always positive and only valid after calling and when returns true.
If the parameter is null, then the default value is new Vector3(0, 1, 0)
Returns the linear velocity of the floor at the last collision point. Only valid after calling or and when returns true.
Locks or unlocks the specified axis depending on the value of lock. See also , and .
Returns true if the specified axis is locked. See also , and .
Returns the number of times the body collided and changed direction during the last call to or .
Returns a , which contains information about a collision that occurred during the last call to or . Since the body can collide several times in a single call to , you must specify the index of the collision in the range 0 to ( - 1).
Returns a , which contains information about the latest collision that occurred during the last call to .
Kinematic bodies are special types of bodies that are meant to be user-controlled. They are not affected by physics at all; to other types of bodies, such as a character or a rigid body, these are the same as a static body. However, they have two main uses:
Simulated motion: When these bodies are moved manually, either from code or from an (with set to "physics"), the physics will automatically compute an estimate of their linear and angular velocity. This makes them very useful for moving platforms or other AnimationPlayer-controlled objects (like a door, a bridge that opens, etc).
Kinematic characters: KinematicBody2D also has an API for moving objects (the and methods) while performing collision tests. This makes them really useful to implement characters that collide against a world, but don't require advanced physics.
Add the last platform velocity when you leave a moving platform.
Add the last platform velocity when you leave a moving platform, but any downward motion is ignored. It's useful to keep full jump height even when the platform is moving down.
Do nothing when leaving a platform.
Extra margin used for collision recovery in motion functions (see , , ).
If the body is at least this close to another body, it will consider them to be colliding and will be pushed away before performing the actual motion.
A higher value means it's more flexible for detecting collision, which helps with consistently detecting walls and floors.
A lower value forces the collision algorithm to use more exact detection, so it can be used in cases that specifically require precision, e.g at very low scale to avoid visible jittering, or for stability with a stack of kinematic bodies.
If true, the body's movement will be synchronized to the physics frame. This is useful when animating movement via , for example on moving platforms. Do not use together with or functions.
Sets the behavior to apply when you leave a moving platform. By default, to be physically accurate, when you leave the last platform velocity is applied. See constants for available behavior.
Moves the body along the vector rel_vec. The body will stop if it collides. Returns a , which contains information about the collision when stopped, or when touching another body along the motion.
If test_only is true, the body does not move but the would-be collision information is given.
Moves the body along a vector. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a or , it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes.
This method should be used in (or in a method called by ), as it uses the physics step's delta value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
linear_velocity is the velocity vector in pixels per second. Unlike in , you should not multiply it by delta — the physics engine handles applying the velocity.
up_direction is the up direction, used to determine what is a wall and what is a floor or a ceiling. If set to the default value of Vector2(0, 0), everything is considered a wall. This is useful for topdown games.
If stop_on_slope is true, body will not slide on slopes when you include gravity in linear_velocity and the body is standing still.
If the body collides, it will change direction a maximum of max_slides times before it stops.
floor_max_angle is the maximum angle (in radians) where a slope is still considered a floor (or a ceiling), rather than a wall. The default value equals 45 degrees.
If infinite_inertia is true, body will be able to push nodes, but it won't also detect any collisions with them. If false, it will interact with nodes like with .
Returns the linear_velocity vector, rotated and/or scaled if a slide collision occurred. To get detailed information about collisions that occurred, use .
When the body touches a moving platform, the platform's velocity is automatically added to the body motion. If a collision occurs due to the platform's motion, it will always be first in the slide collisions.
If the parameter is null, then the default value is new Vector2(0, 0)
Moves the body while keeping it attached to slopes. Similar to .
As long as the snap vector is in contact with the ground, the body will remain attached to the surface. This means you must disable snap in order to jump, for example. You can do this by setting snap to (0, 0) or by using instead.
If the parameter is null, then the default value is new Vector2(0, 0)
Checks for collisions without moving the body. Virtually sets the node's position, scale and rotation to that of the given , then tries to move the body along the vector rel_vec. Returns true if a collision would stop the body from moving along the whole path.
Use instead for detecting collision with touching bodies.
Returns true if the body collided with the floor on the last call of or . Otherwise, returns false.
Returns true if the body collided with the ceiling on the last call of or . Otherwise, returns false.
Returns true if the body collided with a wall on the last call of or . Otherwise, returns false.
Returns the surface normal of the floor at the last collision point. Only valid after calling or and when returns true.
Returns the floor's collision angle at the last collision point according to up_direction, which is Vector2.UP by default. This value is always positive and only valid after calling and when returns true.
If the parameter is null, then the default value is new Vector2(0, -1)
Returns the linear velocity of the floor at the last collision point. Only valid after calling or and when returns true.
Returns the number of times the body collided and changed direction during the last call to or .
Returns a , which contains information about a collision that occurred during the last call to or . Since the body can collide several times in a single call to , you must specify the index of the collision in the range 0 to ( - 1).
Example usage:
for i in get_slide_count():
var collision = get_slide_collision(i)
print("Collided with: ", collision.collider.name)
Returns a , which contains information about the latest collision that occurred during the last call to .
Contains collision data for collisions. When a is moved using , it stops if it detects a collision with another body. If a collision is detected, a KinematicCollision object is returned.
This object contains information about the collision, including the colliding object, the remaining motion, and the collision position. This information can be used to calculate a collision response.
The point of collision, in global coordinates.
The colliding body's shape's normal at the point of collision.
The distance the moving object traveled before collision.
The moving object's remaining movement vector.
The moving object's colliding shape.
The colliding body.
The colliding body's unique instance ID. See .
The colliding body's used by the .
The colliding body's shape.
The colliding shape's index. See .
The colliding object's velocity.
The colliding body's metadata. See .
The collision angle according to up_direction, which is Vector3.UP by default. This value is always positive.
If the parameter is null, then the default value is new Vector3(0, 1, 0)
Contains collision data for collisions. When a is moved using , it stops if it detects a collision with another body. If a collision is detected, a KinematicCollision2D object is returned.
This object contains information about the collision, including the colliding object, the remaining motion, and the collision position. This information can be used to calculate a collision response.
The point of collision, in global coordinates.
The colliding body's shape's normal at the point of collision.
The distance the moving object traveled before collision.
The moving object's remaining movement vector.
The moving object's colliding shape.
The colliding body.
The colliding body's unique instance ID. See .
The colliding body's used by the .
The colliding body's shape.
The colliding shape's index. See .
The colliding object's velocity.
The colliding body's metadata. See .
The collision angle according to up_direction, which is Vector2.UP by default. This value is always positive.
If the parameter is null, then the default value is new Vector2(0, -1)
Label displays plain text on the screen. It gives you control over the horizontal and vertical alignment and can wrap the text inside the node's bounding rectangle. It doesn't support bold, italics, or other formatting. For that, use instead.
Note: Contrarily to most other s, Label's defaults to (i.e. it doesn't react to mouse input events). This implies that a label won't display any configured , unless you change its mouse filter.
Note: Unicode characters after 0xffff (such as most emoji) are not supported on Windows. They will display as unknown characters instead. This will be resolved in Godot 4.0.
Align rows to the left (default).
Align rows centered.
Align rows to the right.
Expand row whitespaces to fit the width.
Align the whole text to the top.
Align the whole text to the center.
Align the whole text to the bottom.
Align the whole text by spreading the rows.
The text to display on screen.
Controls the text's horizontal align. Supports left, center, right, and fill, or justify. Set it to one of the constants.
Controls the text's vertical align. Supports top, center, bottom, and fill. Set it to one of the constants.
If true, wraps the text inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text.
If true, the Label only shows the text that fits inside its bounding rectangle and will clip text horizontally.
If true, all the text displays as UPPERCASE.
Restricts the number of characters to display. Set to -1 to disable.
Limits the amount of visible characters. If you set percent_visible to 0.5, only up to half of the text's characters will display on screen. Useful to animate the text in a dialog box.
The node ignores the first lines_skipped lines before it starts to display text.
Limits the lines of text the node shows on screen.
Returns the font size in pixels.
Returns the amount of lines of text the Label has.
Returns the number of lines shown. Useful if the 's height cannot currently display all lines.
Returns the total number of printable characters in the text (excluding spaces and newlines).
Label3D displays plain text in a 3D world. It gives you control over the horizontal and vertical alignment.
Align rows to the left (default).
Align rows centered.
Align rows to the right.
Expand row whitespaces to fit the width.
If set, lights in the environment affect the label.
If set, text can be seen from the back as well. If not, the text is invisible when looking at it from behind.
Disables the depth test, so this object is drawn on top of all others. However, objects drawn after it in the draw order may cover it.
Label is scaled by depth so that it always appears the same size on screen.
Represents the size of the enum.
This mode performs standard alpha blending. It can display translucent areas, but transparency sorting issues may be visible when multiple transparent materials are overlapping.
This mode only allows fully transparent or fully opaque pixels. This mode is also known as alpha testing or 1-bit transparency.
Note: This mode might have issues with anti-aliased fonts and outlines, try adjusting or using SDF font.
Note: When using text with overlapping glyphs (e.g., cursive scripts), this mode might have transparency sorting issues between the main text and the outline.
This mode draws fully opaque pixels in the depth prepass. This is slower than or , but it allows displaying translucent areas and smooth edges while using proper sorting.
Note: When using text with overlapping glyphs (e.g., cursive scripts), this mode might have transparency sorting issues between the main text and the outline.
Align the whole text to the top.
Align the whole text to the center.
Align the whole text to the bottom.
Align the whole text by spreading the rows.
The size of one pixel's width on the label to scale it in 3D.
The text drawing offset (in pixels).
The billboard mode to use for the label. See for possible values.
If true, the in the has effects on the label.
If true, text can be seen from the back as well, if false, it is invisible when looking at it from behind.
If true, depth testing is disabled and the object will be drawn in render order.
If true, the label is rendered at the same size regardless of distance.
The alpha cutting mode to use for the sprite. See for possible values.
Threshold at which the alpha scissor will discard values.
Sets the render priority for the text. Higher priority objects will be sorted in front of lower priority objects.
Note: This only applies if is set to (default value).
Note: This only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority).
Sets the render priority for the text outline. Higher priority objects will be sorted in front of lower priority objects.
Note: This only applies if is set to (default value).
Note: This only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority).
Text of the .
The tint of 's outline.
The text to display on screen.
used for the 's text.
Controls the text's horizontal alignment. Supports left, center, right. Set it to one of the constants.
Controls the text's vertical alignment. Supports top, center, bottom. Set it to one of the constants.
If true, all the text displays as UPPERCASE.
Vertical space between lines in multiline .
If true, wraps the text to the .
Text width (in pixels), used for autowrap and fill alignment.
If true, the specified flag will be enabled. See for a list of flags.
Returns the value of the specified flag.
Returns a with the label's vertices following its current configuration (such as its ).
Deprecated (will be removed in Godot 4.0). A capable of storing many smaller textures with offsets.
You can dynamically add pieces (s) to this using different offsets.
Adds texture to this , starting on offset ofs.
Sets the offset of the piece with the index idx to ofs.
Sets the of the piece with index idx to texture.
Sets the size of this .
Clears the .
Returns the number of pieces currently in this .
Returns the offset of the piece with the index idx.
Returns the of the piece with the index idx.
Light is the abstract base class for light nodes. As it can't be instanced, it shouldn't be used directly. Other types of light nodes inherit from it. Light contains the common variables and parameters used for lighting.
Light is ignored when baking.
Note: Hiding a light does not affect baking.
Only indirect lighting will be baked (default).
Both direct and indirect light will be baked.
Note: You should hide the light if you don't want it to appear twice (dynamic and baked).
Constant for accessing .
Constant for accessing .
Constant for accessing .
Constant for accessing .
Constant for accessing or .
Constant for accessing or .
Constant for accessing .
Constant for accessing .
Constant for accessing .
Constant for accessing .
Constant for accessing .
Constant for accessing .
Constant for accessing .
Constant for accessing .
Constant for accessing .
Constant for accessing .
Represents the size of the enum.
The light's color. An overbright color can be used to achieve a result equivalent to increasing the light's .
The light's strength multiplier (this is not a physical unit). For and , changing this value will only change the light color's intensity, not the light's radius.
Secondary multiplier used with indirect light (light bounces). This works on both and .
The size of the light in Godot units. Only considered in baked lightmaps and only if is set to . Increasing this value will make the shadows appear blurrier. This can be used to simulate area lights to an extent.
If true, the light's effect is reversed, darkening areas and casting bright shadows.
The intensity of the specular blob in objects affected by the light. At 0, the light becomes a pure diffuse light. When not baking emission, this can be used to avoid unrealistic reflections when placing lights above an emissive surface.
The light's bake mode. See .
The light will affect objects in the selected layers.
If true, the light will cast shadows.
The color of shadows cast by this light.
Used to adjust shadow appearance. Too small a value results in self-shadowing ("shadow acne"), while too large a value causes shadows to separate from casters ("peter-panning"). Adjust as needed.
Attempts to reduce gap by rendering screen-space contact shadows. This has a performance impact, especially at higher values.
Note: Contact shadows can look broken, so leaving this property to 0.0 is recommended.
If true, reverses the backface culling of the mesh. This can be useful when you have a flat mesh that has a light behind it. If you need to cast a shadow on both sides of the mesh, set the mesh to use double-sided shadows with .
If true, the light only appears in the editor and will not be visible at runtime.
Sets the value of the specified parameter.
Returns the value of the specified parameter.
Casts light in a 2D environment. Light is defined by a (usually grayscale) texture, a color, an energy value, a mode (see constants), and various other parameters (range and shadows-related).
Note: Light2D can also be used as a mask.
No filter applies to the shadow map. See .
Percentage closer filtering (3 samples) applies to the shadow map. See .
Percentage closer filtering (5 samples) applies to the shadow map. See .
Percentage closer filtering (7 samples) applies to the shadow map. See .
Percentage closer filtering (9 samples) applies to the shadow map. See .
Percentage closer filtering (13 samples) applies to the shadow map. See .
Adds the value of pixels corresponding to the Light2D to the values of pixels under it. This is the common behavior of a light.
Subtracts the value of pixels corresponding to the Light2D to the values of pixels under it, resulting in inversed light effect.
Mix the value of pixels corresponding to the Light2D to the values of pixels under it by linear interpolation.
The light texture of the Light2D is used as a mask, hiding or revealing parts of the screen underneath depending on the value of each pixel of the light (mask) texture.
If true, Light2D will emit light.
If true, Light2D will only appear when editing the scene.
used for the Light2D's appearance.
The offset of the Light2D's texture.
The texture's scale factor.
The Light2D's .
The Light2D's energy value. The larger the value, the stronger the light.
The Light2D's mode. See constants for values.
The height of the Light2D. Used with 2D normal mapping.
Minimum z value of objects that are affected by the Light2D.
Maximum z value of objects that are affected by the Light2D.
Minimum layer value of objects that are affected by the Light2D.
Maximum layer value of objects that are affected by the Light2D.
The layer mask. Only objects with a matching mask will be affected by the Light2D.
If true, the Light2D will cast shadows.
of shadows cast by the Light2D.
Shadow buffer size.
Smooth shadow gradient length.
Shadow filter type. See for possible values.
Smoothing value for shadows.
The shadow mask. Used with to cast shadows. Only occluders with a matching light mask will cast shadows.
Occludes light cast by a Light2D, casting shadows. The LightOccluder2D must be provided with an in order for the shadow to be computed.
The used to compute the shadow.
The LightOccluder2D's light mask. The LightOccluder2D will cast shadows only from Light2D(s) that have the same light mask(s).
A line through several points in 2D space. Supports varying width and color over the line's length, texturing, and several cap/joint types.
Note: By default, Godot can only draw up to 4,096 polygon points at a time. To increase this limit, open the Project Settings and increase and .
Takes the left pixels of the texture and renders it over the whole line.
Tiles the texture over the line. The texture must be imported with Repeat enabled for it to work properly.
Stretches the texture across the line. Import the texture with Repeat disabled for best results.
Don't draw a line cap.
Draws the line cap as a box.
Draws the line cap as a circle.
The line's joints will be pointy. If sharp_limit is greater than the rotation of a joint, it becomes a bevel joint instead.
The line's joints will be bevelled/chamfered.
The line's joints will be rounded.
The points that form the lines. The line is drawn between every point set in this array. Points are interpreted as local vectors.
The line's width.
The line's width varies with the curve. The original width is simply multiply by the value of the Curve.
The line's color. Will not be used if a gradient is set.
The gradient is drawn through the whole line from start to finish. The default color will not be used if a gradient is set.
The texture used for the line's texture. Uses texture_mode for drawing style.
The style to render the texture on the line. Use constants.
The style for the points between the start and the end.
Controls the style of the line's first point. Use constants.
Controls the style of the line's last point. Use constants.
The direction difference in radians between vector points. This value is only used if is set to .
The smoothness of the rounded joints and caps. Higher values result in smoother corners, but are more demanding to render and update. This is only used if a cap or joint is set as round.
Note: The default value is tuned for lines with the default . For thin lines, this value should be reduced to a number between 2 and 4 to improve performance.
If true, the line's border will attempt to perform antialiasing by drawing thin OpenGL smooth lines on the line's edges.
Note: Line2D is not accelerated by batching if is true.
Note: Due to how it works, built-in antialiasing will not look correct for translucent lines and may not work on certain platforms. As a workaround, install the Antialiased Line2D add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
Overwrites the position of the point at index index with the supplied position.
Returns the position of the point at index index.
Returns the amount of points in the line.
Adds a point with the specified position relative to the line's own position. Appends the new point at the end of the point list.
If index is given, the new point is inserted before the existing point identified by index index. Every existing point starting from index is shifted further down the list of points. The index must be greater than or equal to 0 and must not exceed the number of existing points in the line. See .
Removes the point at index index from the line.
Removes all points from the line.
LineEdit provides a single-line string editor, used for text fields.
It features many built-in shortcuts which will always be available (Ctrl here maps to Command on macOS):
- Ctrl + C: Copy
- Ctrl + X: Cut
- Ctrl + V or Ctrl + Y: Paste/"yank"
- Ctrl + Z: Undo
- Ctrl + Shift + Z: Redo
- Ctrl + U: Delete text from the cursor position to the beginning of the line
- Ctrl + K: Delete text from the cursor position to the end of the line
- Ctrl + A: Select all text
- Up/Down arrow: Move the cursor to the beginning/end of the line
On macOS, some extra keyboard shortcuts are available:
- Ctrl + F: Like the right arrow key, move the cursor one character right
- Ctrl + B: Like the left arrow key, move the cursor one character left
- Ctrl + P: Like the up arrow key, move the cursor to the previous line
- Ctrl + N: Like the down arrow key, move the cursor to the next line
- Ctrl + D: Like the Delete key, delete the character on the right side of cursor
- Ctrl + H: Like the Backspace key, delete the character on the left side of the cursor
- Command + Left arrow: Like the Home key, move the cursor to the beginning of the line
- Command + Right arrow: Like the End key, move the cursor to the end of the line
Aligns the text on the left-hand side of the .
Centers the text in the middle of the .
Aligns the text on the right-hand side of the .
Stretches whitespaces to fit the 's width.
Cuts (copies and clears) the selected text.
Copies the selected text.
Pastes the clipboard text over the selected text (or at the cursor's position).
Non-printable escape characters are automatically stripped from the OS clipboard via String.strip_escapes.
Erases the whole text.
Selects the whole text.
Undoes the previous action.
Reverse the last undo action.
Represents the size of the enum.
String value of the .
Note: Changing text using this property won't emit the text_changed signal.
Text alignment as defined in the enum.
Maximum amount of characters that can be entered inside the . If 0, there is no limit.
When a limit is defined, characters that would exceed are truncated. This happens both for existing contents when setting the max length, or for new text inserted in the , including pasting. If any input text is truncated, the text_change_rejected signal is emitted with the truncated substring as parameter.
Example:
text = "Hello world"
max_length = 5
# `text` becomes "Hello".
max_length = 10
text += " goodbye"
# `text` becomes "Hello good".
# `text_change_rejected` is emitted with "bye" as parameter.
If false, existing text cannot be modified and new text cannot be added.
If true, every character is replaced with the secret character (see ).
The character to use to mask secret input (defaults to "*"). Only a single character can be used as the secret character.
If true, the width will increase to stay longer than the . It will not compress if the is shortened.
If true, the context menu will appear when right-clicked.
If true, the native virtual keyboard is shown when focused on platforms that support it.
If true, the will show a clear button if text is not empty, which can be used to clear the text quickly.
If false, using shortcuts will be disabled.
If false, using middle mouse button to paste clipboard will be disabled.
Note: This method is only implemented on Linux.
If false, it's impossible to select the text using mouse nor keyboard.
If true, the selected text will be deselected when focus is lost.
Sets the icon that will appear in the right end of the if there's no , or always, if is set to false.
Text shown when the is empty. It is not the 's default value (see ).
Opacity of the . From 0 to 1.
If true, the caret (visual cursor) blinks.
Duration (in seconds) of a caret's blinking cycle.
The cursor's position inside the . When set, the text may scroll to accommodate it.
Erases the 's .
Selects characters inside between from and to. By default, from is at the beginning and to at the end.
text = "Welcome"
select() # Will select "Welcome".
select(4) # Will select "ome".
select(2, 5) # Will select "lco".
Selects the whole .
Clears the current selection.
Returns true if the user has selected text.
Returns the selection begin column.
Returns the selection end column.
Returns the scroll offset due to , as a number of characters.
Adds text after the cursor. If the resulting value is longer than , nothing happens.
Deletes one character at the cursor's current position (equivalent to pressing the Delete key).
Deletes a section of the going from position from_column to to_column. Both parameters should be within the text's length.
Executes a given action as defined in the enum.
Returns the of this . By default, this menu is displayed when right-clicking on the .
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Line shape for 2D collisions. It works like a 2D plane and will not allow any physics body to go to the negative side. Not recommended for rigid bodies, and usually not recommended for static bodies either because it forces checks against it on every frame.
The line's normal.
The line's distance from the origin.
This kind of button is primarily used when the interaction with the button causes a context change (like linking to a web page).
See also which contains common properties and methods associated with this node.
The LinkButton will always show an underline at the bottom of its text.
The LinkButton will show an underline at the bottom of its text when the mouse cursor is over it.
The LinkButton will never show an underline at the bottom of its text.
The button's text that will be displayed inside the button's area.
Determines when to show the underline. See for options.
Once added to the scene tree and enabled using , this node will override the location sounds are heard from. This can be used to listen from a location different from the .
Enables the listener. This will override the current camera's listener.
Disables the listener to use the current camera's listener instead.
Returns true if the listener was made current using , false otherwise.
Note: There may be more than one Listener marked as "current" in the scene tree, but only the one that was made current last will be used.
Returns the listener's global orthonormalized .
Once added to the scene tree and enabled using , this node will override the location sounds are heard from. Only one can be current. Using will disable the previous .
If there is no active in the current , center of the screen will be used as a hearing point for the audio. needs to be inside to function.
Makes the active, setting it as the hearing point for the sounds. If there is already another active , it will be disabled.
This method will have no effect if the is not added to .
Disables the . If it's not set as current, this method will have no effect.
Returns true if this is currently active.
is the abstract base class for a Godot project's game loop. It is inherited by , which is the default game loop implementation used in Godot projects, though it is also possible to write and use one's own subclass instead of the scene tree.
Upon the application start, a implementation must be provided to the OS; otherwise, the application will exit. This happens automatically (and a is created) unless a main is provided from the command line (with e.g. godot -s my_loop.gd, which should then be a implementation.
Here is an example script implementing a simple :
extends MainLoop
var time_elapsed = 0
var keys_typed = []
var quit = false
func _initialize():
print("Initialized:")
print(" Starting time: %s" % str(time_elapsed))
func _idle(delta):
time_elapsed += delta
# Return true to end the main loop.
return quit
func _input_event(event):
# Record keys.
if event is InputEventKey and event.pressed and !event.echo:
keys_typed.append(OS.get_scancode_string(event.scancode))
# Quit on Escape press.
if event.scancode == KEY_ESCAPE:
quit = true
# Quit on any mouse click.
if event is InputEventMouseButton:
quit = true
func _finalize():
print("Finalized:")
print(" End time: %s" % str(time_elapsed))
print(" Keys typed: %s" % var2str(keys_typed))
Notification received from the OS when the mouse enters the game window.
Implemented on desktop and web platforms.
Notification received from the OS when the mouse leaves the game window.
Implemented on desktop and web platforms.
Notification received from the OS when the game window is focused.
Implemented on all platforms.
Notification received from the OS when the game window is unfocused.
Implemented on all platforms.
Notification received from the OS when a quit request is sent (e.g. closing the window with a "Close" button or Alt+F4).
Implemented on desktop platforms.
Notification received from the OS when a go back request is sent (e.g. pressing the "Back" button on Android).
Specific to the Android platform.
Notification received from the OS when an unfocus request is sent (e.g. another OS window wants to take the focus).
No supported platforms currently send this notification.
Notification received from the OS when the application is exceeding its allocated memory.
Specific to the iOS platform.
Notification received when translations may have changed. Can be triggered by the user changing the locale. Can be used to respond to language changes, for example to change the UI strings on the fly. Useful when working with the built-in translation support, like .
Notification received from the OS when a request for "About" information is sent.
Specific to the macOS platform.
Notification received from Godot's crash handler when the engine is about to crash.
Implemented on desktop platforms if the crash handler is enabled.
Notification received from the OS when an update of the Input Method Engine occurs (e.g. change of IME cursor position or composition string).
Specific to the macOS platform.
Notification received from the OS when the app is resumed.
Specific to the Android platform.
Notification received from the OS when the app is paused.
Specific to the Android platform.
Called when files are dragged from the OS file manager and dropped in the game window. The arguments are a list of file paths and the identifier of the screen where the drag originated.
Called before the program exits.
Called when the user performs an action in the system global menu (e.g. the Mac OS menu bar).
Called each idle frame with the time since the last idle frame as argument (in seconds). Equivalent to .
If implemented, the method must return a boolean value. true ends the main loop, while false lets it proceed to the next frame.
Called once during initialization.
Called whenever an is received by the main loop.
Deprecated callback, does not do anything. Use to parse text input. Will be removed in Godot 4.0.
Called each physics frame with the time since the last physics frame as argument (delta, in seconds). Equivalent to .
If implemented, the method must return a boolean value. true ends the main loop, while false lets it proceed to the next frame.
Should not be called manually, override instead. Will be removed in Godot 4.0.
Should not be called manually, override instead. Will be removed in Godot 4.0.
Should not be called manually, override instead. Will be removed in Godot 4.0.
Should not be called manually, override instead. Will be removed in Godot 4.0.
Should not be called manually, override instead. Will be removed in Godot 4.0.
Should not be called manually, override instead. Will be removed in Godot 4.0.
Adds a top, left, bottom, and right margin to all nodes that are direct children of the container. To control the 's margin, use the margin_* theme properties listed below.
Note: Be careful, margin values are different than the constant margin values. If you want to change the custom margin values of the by code, you should use the following examples:
# This code sample assumes the current script is extending MarginContainer.
var margin_value = 100
add_constant_override("margin_top", margin_value)
add_constant_override("margin_left", margin_value)
add_constant_override("margin_bottom", margin_value)
add_constant_override("margin_right", margin_value)
Material is a base used for coloring and shading geometry. All materials inherit from it and almost all derived nodes carry a Material. A few flags and parameters are shared between all material types and are configured here.
Maximum value for the parameter.
Minimum value for the parameter.
Sets the render priority for transparent objects in 3D scenes. Higher priority objects will be sorted in front of lower priority objects.
Note: This only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority).
Sets the to be used for the next pass. This renders the object again using a different material.
Note: This only applies to s and s with type "Spatial".
Special button that brings up a when clicked.
New items can be created inside this using get_popup().add_item("My Item Name"). You can also create them directly from the editor. To do so, select the node, then in the toolbar at the top of the 2D editor, click Items then click Add in the popup. You will be able to give each item new properties.
See also which contains common properties and methods associated with this node.
If true, when the cursor hovers above another within the same parent which also has switch_on_hover enabled, it will close the current and open the other one.
Returns the contained in this button.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
If true, shortcuts are disabled and cannot be used to trigger the button.
Mesh is a type of that contains vertex array-based geometry, divided in surfaces. Each surface contains a completely separate array and a material used to draw it. Design wise, a mesh with multiple surfaces is preferred to a single surface, because objects created in 3D editing software commonly contain multiple materials.
Blend shapes are normalized.
Blend shapes are relative to base weight.
Render array as points (one vertex equals one point).
Render array as lines (every two vertices a line is created).
Render array as line strip.
Render array as line loop (like line strip, but closed).
Render array as triangles (every three vertices a triangle is created).
Render array as triangle strips.
Render array as triangle fans.
Mesh array contains vertices. All meshes require a vertex array so this should always be present.
Mesh array contains normals.
Mesh array contains tangents.
Mesh array contains colors.
Mesh array contains UVs.
Mesh array contains second UV.
Mesh array contains bones.
Mesh array contains bone weights.
Mesh array uses indices.
Used internally to calculate other ARRAY_COMPRESS_* enum values. Do not use.
Flag used to mark a compressed (half float) vertex array.
Flag used to mark a compressed (half float) normal array.
Flag used to mark a compressed (half float) tangent array.
Flag used to mark a compressed (half float) color array.
Note: If this flag is enabled, vertex colors will be stored as 8-bit unsigned integers. This will clamp overbright colors to Color(1, 1, 1, 1) and reduce colors' precision.
Flag used to mark a compressed (half float) UV coordinates array.
Flag used to mark a compressed (half float) UV coordinates array for the second UV coordinates.
Flag used to mark a compressed bone array.
Flag used to mark a compressed (half float) weight array.
Flag used to mark a compressed index array.
Flag used to mark that the array contains 2D vertices.
Flag used to mark that the array uses 16-bit bones instead of 8-bit.
Flag used to mark that the array uses an octahedral representation of normal and tangent vectors rather than cartesian.
Used to set flags , , , , , , , and quickly.
Note: Since this flag enables , vertex colors will be stored as 8-bit unsigned integers. This will clamp overbright colors to Color(1, 1, 1, 1) and reduce colors' precision.
Array of vertices.
Array of normals.
Array of tangents as an array of floats, 4 floats per tangent.
Array of colors.
Array of UV coordinates.
Array of second set of UV coordinates.
Array of bone data.
Array of weights.
Array of indices.
Represents the size of the enum.
Sets a hint to be used for lightmap resolution in . Overrides .
Returns the smallest enclosing this mesh in local space. Not affected by custom_aabb. See also .
Note: This is only implemented for and .
Returns the amount of surfaces that the holds.
Returns the arrays for the vertices, normals, uvs, etc. that make up the requested surface (see ).
Returns the blend shape arrays for the requested surface.
Sets a for a given surface. Surface will be rendered using this material.
Returns a in a given surface. Surface is rendered using this material.
Calculate a from the mesh.
Calculate a from the mesh.
If clean is true (default), duplicate and interior vertices are removed automatically. You can set it to false to make the process faster if not needed.
If simplify is true, the geometry can be further simplified to reduce the amount of vertices. Disabled by default.
Calculate an outline mesh at a defined offset (margin) from the original mesh.
Note: This method typically returns the vertices in reverse order (e.g. clockwise to counterclockwise).
Returns all the vertices that make up the faces of the mesh. Each three vertices represent one triangle.
Generate a from the mesh.
MeshDataTool provides access to individual vertices in a . It allows users to read and edit vertex data of meshes. It also creates an array of faces and edges.
To use MeshDataTool, load a mesh with . When you are finished editing the data commit the data to a mesh with .
Below is an example of how MeshDataTool may be used.
var mesh = ArrayMesh.new()
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, CubeMesh.new().get_mesh_arrays())
var mdt = MeshDataTool.new()
mdt.create_from_surface(mesh, 0)
for i in range(mdt.get_vertex_count()):
var vertex = mdt.get_vertex(i)
# In this example we extend the mesh by one unit, which results in separated faces as it is flat shaded.
vertex += mdt.get_vertex_normal(i)
# Save your change.
mdt.set_vertex(i, vertex)
mesh.surface_remove(0)
mdt.commit_to_surface(mesh)
var mi = MeshInstance.new()
mi.mesh = mesh
add_child(mi)
See also , and for procedural geometry generation.
Note: Godot uses clockwise winding order for front faces of triangle primitive modes.
Clears all data currently in MeshDataTool.
Uses specified surface of given to populate data for MeshDataTool.
Requires with primitive type .
Adds a new surface to specified with edited data.
Returns the 's format. Format is an integer made up of format flags combined together. For example, a mesh containing both vertices and normals would return a format of 3 because is 1 and is 2.
See for a list of format flags.
Returns the total number of vertices in .
Returns the number of edges in this .
Returns the number of faces in this .
Sets the position of the given vertex.
Returns the vertex at given index.
Sets the normal of the given vertex.
Returns the normal of the given vertex.
Sets the tangent of the given vertex.
Returns the tangent of the given vertex.
Sets the UV of the given vertex.
Returns the UV of the given vertex.
Sets the UV2 of the given vertex.
Returns the UV2 of the given vertex.
Sets the color of the given vertex.
Returns the color of the given vertex.
Sets the bones of the given vertex.
Returns the bones of the given vertex.
Sets the bone weights of the given vertex.
Returns bone weights of the given vertex.
Sets the metadata associated with the given vertex.
Returns the metadata associated with the given vertex.
Returns an array of edges that share the given vertex.
Returns an array of faces that share the given vertex.
Returns index of specified vertex connected to given edge.
Vertex argument can only be 0 or 1 because edges are comprised of two vertices.
Returns array of faces that touch given edge.
Sets the metadata of the given edge.
Returns meta information assigned to given edge.
Returns the specified vertex of the given face.
Vertex argument must be either 0, 1, or 2 because faces contain three vertices.
Returns specified edge associated with given face.
Edge argument must be either 0, 1, or 2 because a face only has three edges.
Sets the metadata of the given face.
Returns the metadata associated with the given face.
Calculates and returns the face normal of the given face.
Sets the material to be used by newly-constructed .
Returns the material assigned to the .
MeshInstance is a node that takes a resource and adds it to the current scenario by creating an instance of it. This is the class most often used to get 3D geometry rendered and can be used to instance a single in many places. This allows reusing geometry, which can save on resources. When a has to be instanced more than thousands of times at close proximity, consider using a in a instead.
The resource for the instance.
Sets the skin to be used by this instance.
to the associated with the instance.
If true, normals are transformed when software skinning is used. Set to false when normals are not needed for better performance.
See for details about how software skinning is enabled.
Returns the number of surface override materials.
Sets the override for the specified surface of the resource. This material is associated with this rather than with the resource.
Returns the override for a surface of the resource.
Note: This function only returns override materials associated with this . Consider using or to get materials associated with the resource.
Returns the that will be used by the when drawing. This can return the , the surface override defined in this , or the surface defined in the . For example, if is used, all surfaces will return the override material.
This helper creates a child node with a collision shape calculated from the mesh geometry. It's mainly used for testing.
This helper creates a child node with multiple collision shapes calculated from the mesh geometry via convex decomposition. It's mainly used for testing.
This helper creates a child node with a collision shape calculated from the mesh geometry. It's mainly used for testing.
If clean is true (default), duplicate and interior vertices are removed automatically. You can set it to false to make the process faster if not needed.
If simplify is true, the geometry can be further simplified to reduce the amount of vertices. Disabled by default.
This helper creates a child node with gizmos at every vertex calculated from the mesh geometry. It's mainly used for testing.
Returns true if this can be merged with the specified other_mesh_instance, using the function.
In order to be mergeable, properties of the must match, and each surface must match, in terms of material, attributes and vertex format.
This function can merge together the data from several source s into a single destination (the MeshInstance the function is called from). This is primarily useful for improving performance by reducing the number of drawcalls and s.
Merging should only be attempted for simple meshes that do not contain animation.
The final vertices can either be returned in global space, or in local space relative to the destination global transform (the destination Node must be inside the for local space to work).
The function will make a final check for compatibility between the s by default, this should always be used unless you have previously checked for compatibility using . If the compatibility check is omitted and the meshes are merged, you may see rendering errors.
Note: The requirements for similarity between meshes are quite stringent. They can be checked using the function prior to calling .
Also note that any initial data in the destination data will be discarded.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Node used for displaying a in 2D. A can be automatically created from an existing via a tool in the editor toolbar. Select the node, then choose Sprite > Convert to MeshInstance2D at the top of the 2D editor viewport.
The that will be drawn by the .
The that will be used if using the default . Can be accessed as TEXTURE in CanvasItem shader.
The normal map that will be used if using the default .
Note: Godot expects the normal map to use X+, Y+, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.
A library of meshes. Contains a list of resources, each with a name and ID. Each item can also include collision and navigation shapes. This resource is used in .
Creates a new item in the library with the given ID.
You can get an unused ID from .
Sets the item's name.
This name is shown in the editor. It can also be used to look up the item later using .
Sets the item's mesh.
Sets the transform to apply to the item's mesh.
Sets the item's navigation mesh.
Sets the transform to apply to the item's navigation mesh.
Sets an item's collision shapes.
The array should consist of objects, each followed by a that will be applied to it. For shapes that should not have a transform, use Transform.IDENTITY.
Sets a texture to use as the item's preview icon in the editor.
Returns the item's name.
Returns the item's mesh.
Returns the transform applied to the item's mesh.
Returns the item's navigation mesh.
Returns the transform applied to the item's navigation mesh.
Returns an item's collision shapes.
The array consists of each followed by its .
When running in the editor, returns a generated item preview (a 3D rendering in isometric perspective). When used in a running project, returns the manually-defined item preview which can be set using . Returns an empty if no preview was manually set in a running project.
Removes the item.
Returns the first item with the given name.
Clears the library.
Returns the list of item IDs in use.
Gets an unused ID for a new item.
Simple texture that uses a mesh to draw itself. It's limited because flags can't be changed and region drawing is not supported.
Sets the mesh used to draw. It must be a mesh using 2D vertices.
Sets the base texture that the Mesh will use to draw.
Sets the size of the image, needed for reference.
is similar to a combination of and . It calls a method providing an interpolated value as a parameter. See for more usage information.
Note: is the only correct way to create . Any created manually will not function correctly.
Sets the time in seconds after which the will start interpolating. By default there's no delay.
Sets the type of used transition from . If not set, the default transition is used from the that contains this Tweener.
Sets the type of used easing from . If not set, the default easing is used from the that contains this Tweener.
This is a generic mobile VR implementation where you need to provide details about the phone and HMD used. It does not rely on any existing framework. This is the most basic interface we have. For the best effect, you need a mobile phone with a gyroscope and accelerometer.
Note that even though there is no positional tracking, the camera will assume the headset is at a height of 1.85 meters. You can change this by setting .
You can initialise this interface as follows:
var interface = ARVRServer.find_interface("Native mobile")
if interface and interface.initialize():
get_viewport().arvr = true
The height at which the camera is placed in relation to the ground (i.e. node).
The interocular distance, also known as the interpupillary distance. The distance between the pupils of the left and right eye.
The width of the display in centimeters.
The distance between the display and the lenses inside of the device in centimeters.
The oversample setting. Because of the lens distortion we have to render our buffers at a higher resolution then the screen can natively handle. A value between 1.5 and 2.0 often provides good results but at the cost of performance.
The k1 lens factor is one of the two constants that define the strength of the lens used and directly influences the lens distortion effect.
The k2 lens factor, see k1.
MultiMesh provides low-level mesh instancing. Drawing thousands of nodes can be slow, since each object is submitted to the GPU then drawn individually.
MultiMesh is much faster as it can draw thousands of instances with a single draw call, resulting in less API overhead.
As a drawback, if the instances are too far away from each other, performance may be reduced as every single instance will always render (they are spatially indexed as one, for the whole object).
Since instances may have any behavior, the AABB used for visibility must be provided by the user.
Always interpolate using Basis lerping, which can produce warping artifacts in some situations.
Attempt to interpolate using Basis slerping (spherical linear interpolation) where possible, otherwise fall back to lerping.
Use this when using 2D transforms.
Use this when using 3D transforms.
Use when you are not using per-instance custom data.
Compress custom_data into 8 bits when passing to shader. This uses less memory and can be faster, but loses precision and range. Floats packed into 8 bits can only represent values between 0 and 1, numbers outside that range will be clamped.
The passed into will use 4 floats. Use this for highest precision.
Use when you are not using per-instance s.
Compress data into 8 bits when passing to shader. This uses less memory and can be faster, but the loses precision.
The passed into will use 4 floats. Use this for highest precision .
Format of colors in color array that gets passed to shader.
Format of transform used to transform mesh, either 2D or 3D.
Format of custom data in custom data array that gets passed to shader.
Number of instances that will get drawn. This clears and (re)sizes the buffers. By default, all instances are drawn but you can limit this with .
Limits the number of instances drawn, -1 draws all instances. Changing this does not change the sizes of the buffers.
Mesh to be drawn.
Choose whether to use an interpolation method that favors speed or quality.
When using low physics tick rates (typically below 20) or high rates of object rotation, you may get better results from the high quality setting.
Note: Fast quality does not equate to low quality. Except in the special cases mentioned above, the quality should be comparable to high quality.
Sets the for a specific instance.
Sets the for a specific instance.
Returns the of a specific instance.
Returns the of a specific instance.
Sets the color of a specific instance by multiplying the mesh's existing vertex colors.
For the color to take effect, ensure that is non-null on the and is true on the material. If the color doesn't look as expected, make sure the material's albedo color is set to pure white (Color(1, 1, 1)).
Gets a specific instance's color.
Sets custom data for a specific instance. Although is used, it is just a container for 4 floating point numbers. The format of the number can change depending on the used.
Returns the custom data that has been set for a specific instance.
When using physics interpolation, this function allows you to prevent interpolation on an instance in the current physics tick.
This allows you to move instances instantaneously, and should usually be used when initially placing an instance such as a bullet to prevent graphical glitches.
Sets all data related to the instances in one go. This is especially useful when loading the data from disk or preparing the data from GDNative.
All data is packed in one large float array. An array may look like this: Transform for instance 1, color data for instance 1, custom data for instance 1, transform for instance 2, color data for instance 2, etc...
is stored as 12 floats, is stored as 8 floats, COLOR_8BIT / CUSTOM_DATA_8BIT is stored as 1 float (4 bytes as is) and COLOR_FLOAT / CUSTOM_DATA_FLOAT is stored as 4 floats.
An alternative version of which can be used with physics interpolation. This method takes two arrays, and can set the data for the current and previous tick in one go. The renderer will automatically interpolate the data at each frame.
This is useful for situations where the order of instances may change from physics tick to tick, such as particle systems.
When the order of instances is coherent, the simpler can still be used with interpolation.
Returns the visibility axis-aligned bounding box in local space. See also .
is a specialized node to instance s based on a resource.
This is useful to optimize the rendering of a high amount of instances of a given mesh (for example trees in a forest or grass strands).
The resource that will be used and shared among all instances of the .
is a specialized node to instance a resource in 2D.
Usage is the same as .
The that will be drawn by the .
The that will be used if using the default . Can be accessed as TEXTURE in CanvasItem shader.
The normal map that will be used if using the default .
Note: Godot expects the normal map to use X+, Y+, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.
This class implements most of the logic behind the high-level multiplayer API. See also .
By default, has a reference to this class that is used to provide multiplayer capabilities (i.e. RPC/RSET) across the whole scene.
It is possible to override the MultiplayerAPI instance used by specific Nodes by setting the property, effectively allowing to run both client and server in the same scene.
Note: The high-level multiplayer API protocol is an implementation detail and isn't meant to be used by non-Godot servers. It may change without notice.
Used with or to disable a method or property for all RPC calls, making it unavailable. Default for all methods.
Used with or to set a method to be called or a property to be changed only on the remote end, not locally. Analogous to the remote keyword. Calls and property changes are accepted from all remote peers, no matter if they are node's master or puppets.
Used with or to set a method to be called or a property to be changed only on the network master for this node. Analogous to the master keyword. Only accepts calls or property changes from the node's network puppets, see .
Used with or to set a method to be called or a property to be changed only on puppets for this node. Analogous to the puppet keyword. Only accepts calls or property changes from the node's network master, see .
Deprecated. Use instead. Analogous to the slave keyword.
Behave like but also make the call or property change locally. Analogous to the remotesync keyword.
Deprecated. Use instead. Analogous to the sync keyword.
Behave like but also make the call or property change locally. Analogous to the mastersync keyword.
Behave like but also make the call or property change locally. Analogous to the puppetsync keyword.
If true (or if the has set to true), the MultiplayerAPI will allow encoding and decoding of object during RPCs/RSETs.
Warning: Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
If true, the MultiplayerAPI's refuses new incoming connections.
The peer object to handle the RPC system (effectively enabling networking when set). Depending on the peer itself, the MultiplayerAPI will become a network server (check with ) and will set root node's network mode to master, or it will become a regular peer with root node set to puppet. All child nodes are set to inherit the network mode by default. Handling of networking-related events (connection, disconnection, new clients) is done by connecting to MultiplayerAPI's signals.
The root node to use for RPCs. Instead of an absolute path, a relative path will be used to find the node upon which the RPC should be executed.
This effectively allows to have different branches of the scene tree to be managed by different MultiplayerAPI, allowing for example to run both client and server in the same scene.
Sends the given raw bytes to a specific peer identified by id (see ). Default ID is 0, i.e. broadcast to all peers.
Returns true if there is a set.
Returns the unique peer ID of this MultiplayerAPI's .
Returns true if this MultiplayerAPI's is in server mode (listening for connections).
Returns the sender's peer ID for the RPC currently being executed.
Note: If not inside an RPC this method will return 0.
Method used for polling the MultiplayerAPI. You only need to worry about this if you are using override or you set to false. By default, will poll its MultiplayerAPI for you.
Note: This method results in RPCs and RSETs being called, so they will be executed in the same context of this function (e.g. _process, physics, ).
Clears the current MultiplayerAPI network state (you shouldn't call this unless you know what you are doing).
Returns the peer IDs of all connected peers of this MultiplayerAPI's .
Returns the documentation string that was previously set with godot_nativescript_set_class_documentation.
Returns the documentation string that was previously set with godot_nativescript_set_method_documentation.
Returns the documentation string that was previously set with godot_nativescript_set_signal_documentation.
Returns the documentation string that was previously set with godot_nativescript_set_property_documentation.
Constructs a new object of the base type with a script of this type already attached.
Note: Any arguments passed to this function will be ignored and not passed to the native constructor function. This will change with in a future API extension.
Deprecated. node and are deprecated and will be removed in a future version. Use instead.
Provides navigation and pathfinding within a collection of es. By default, these will be automatically collected from child nodes. In addition to basic pathfinding, this class also assists with aligning navigation agents with the meshes they are navigating on.
Defines which direction is up. By default, this is (0, 1, 0), which is the world's "up" direction.
The XZ plane cell size to use for fields.
The cell height to use for fields.
This value is used to detect the near edges to connect compatible regions.
A bitfield determining all navigation map layers the navigation can use on a path query.
Returns the of the navigation map on the .
Deprecated. node and are deprecated and will be removed in a future version. Use instead.
Returns the path between two given points. Points are in local coordinate space. If optimize is true (the default), the agent properties associated with each (radius, height, etc.) are considered in the path calculation, otherwise they are ignored.
Returns the navigation point closest to the given line segment. When enabling use_collision, only considers intersection points between segment and navigation meshes. If multiple intersection points are found, the one closest to the segment start point is returned.
Returns the navigation point closest to the point given. Points are in local coordinate space.
Returns the surface normal at the navigation point closest to the point given. Useful for rotating a navigation agent according to the navigation mesh it moves on.
Returns the owner of the which contains the navigation point closest to the point given. This is usually a .
Deprecated. node and are deprecated and will be removed in a future version. Use instead.
Navigation2D provides navigation and pathfinding within a 2D area, specified as a collection of resources. By default, these are automatically collected from child nodes.
The XY plane cell size to use for fields.
This value is used to detect the near edges to connect compatible regions.
A bitfield determining all navigation map layers the navigation can use on a path query.
Returns the object's .
Deprecated. node and are deprecated and will be removed in a future version. Use instead.
Returns the path between two given points. Points are in local coordinate space. If optimize is true (the default), the path is smoothed by merging path segments where possible.
Returns the navigation point closest to the point given. Points are in local coordinate space.
Returns the owner of the which contains the navigation point closest to the point given. This is usually a .
Navigation2DServer is the server responsible for all 2D navigation. It handles several objects, namely maps, regions and agents.
Maps are made up of regions, which are made of navigation polygons. Together, they define the navigable areas in the 2D world.
Note: Most NavigationServer changes take effect after the next physics frame and not immediately. This includes all changes made to maps, regions or agents by navigation related Nodes in the SceneTree or made through scripts.
For two regions to be connected to each other, they must share a similar edge. An edge is considered connected to another if both of its two vertices are at a distance less than navigation map edge_connection_margin to the respective other edge's vertex.
You may assign navigation layers to regions with , which then can be checked upon when requesting a path with . This allows allowing or forbidding some areas to 2D objects.
To use the collision avoidance system, you may use agents. You can set an agent's target velocity, then the servers will emit a callback with a modified velocity.
Note: The collision avoidance system ignores regions. Using the modified velocity as-is might lead to pushing and agent outside of a navigable area. This is a limitation of the collision avoidance system, any more complex situation may require the use of the physics engine.
This server keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying.
Returns all created navigation map s on the NavigationServer. This returns both 2D and 3D created navigation maps as there is technically no distinction between them.
Create a new map.
Sets the map active.
Returns true if the map is active.
Set the map cell size used to weld the navigation mesh polygons.
Returns the map cell size.
Set the map cell height used to weld the navigation mesh polygons. Note: Currently not implemented.
Returns the map cell height. Note: Currently not implemented.
Set the map edge connection margin used to weld the compatible region edges.
Returns the edge connection margin of the map. The edge connection margin is a distance used to connect two regions.
Returns the navigation path to reach the destination from the origin. navigation_layers is a bitmask of all region layers that are allowed to be in the path.
Returns the point closest to the provided to_point on the navigation mesh surface.
Returns the owner region RID for the point returned by .
Returns all navigation regions s that are currently assigned to the requested navigation map.
Returns all navigation agents s that are currently assigned to the requested navigation map.
This function immediately forces synchronization of the specified navigation map . By default navigation maps are only synchronized at the end of each physics frame. This function can be used to immediately (re)calculate all the navigation meshes and region connections of the navigation map. This makes it possible to query a navigation path for a changed map immediately and in the same frame (multiple times if needed).
Due to technical restrictions the current NavigationServer command queue will be flushed. This means all already queued update commands for this physics frame will be executed, even those intended for other maps, regions and agents not part of the specified map. The expensive computation of the navigation meshes and region connections of a map will only be done for the specified map. Other maps will receive the normal synchronization at the end of the physics frame. Should the specified map receive changes after the forced update it will update again as well when the other maps receive their update.
Avoidance processing and dispatch of the safe_velocity signals is untouched by this function and continues to happen for all maps and agents at the end of the physics frame.
Note: With great power comes great responsibility. This function should only be used by users that really know what they are doing and have a good reason for it. Forcing an immediate update of a navigation map requires locking the NavigationServer and flushing the entire NavigationServer command queue. Not only can this severely impact the performance of a game but it can also introduce bugs if used inappropriately without much foresight.
Creates a new region.
Sets the enter_cost for this region.
Returns the enter_cost of this region.
Sets the travel_cost for this region.
Returns the travel_cost of this region.
Returns true if the provided point in world space is currently owned by the provided navigation region. Owned in this context means that one of the region's navigation mesh polygon faces has a possible position at the closest distance to this point compared to all other navigation meshes from other navigation regions that are also registered on the navigation map of the provided region.
If multiple navigation meshes have positions at equal distance the navigation region whose polygons are processed first wins the ownership. Polygons are processed in the same order that navigation regions were registered on the NavigationServer.
Note: If navigation meshes from different navigation regions overlap (which should be avoided in general) the result might not be what is expected.
Sets the map for the region.
Returns the navigation map the requested region is currently assigned to.
Set the region's navigation layers. This allows selecting regions from a path request (when using ).
Returns the region's navigation layers.
Sets the global transformation for the region.
Sets the navigation mesh for the region.
Returns how many connections this region has with other regions in the map.
Returns the starting point of a connection door. connection is an index between 0 and the return value of .
Returns the ending point of a connection door. connection is an index between 0 and the return value of .
Creates the agent.
Puts the agent in the map.
Returns the navigation map the requested agent is currently assigned to.
Sets the maximum distance to other agents this agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe.
Sets the maximum number of other agents the agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe.
The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to other agents. The larger this number, the sooner this agent will respond to the presence of other agents, but the less freedom this agent has in choosing its velocities. Must be positive.
Sets the radius of the agent.
Sets the maximum speed of the agent. Must be positive.
Sets the current velocity of the agent.
Sets the new target velocity.
Sets the position of the agent in world space.
Returns true if the map got changed the previous frame.
Callback called at the end of the RVO process. If a callback is created manually and the agent is placed on a navigation map it will calculate avoidance for the agent and dispatch the calculated safe_velocity to the receiver object with a signal to the chosen method name.
Note: Created callbacks are always processed independently of the SceneTree state as long as the agent is on a navigation map and not freed. To disable the dispatch of a callback from an agent use again with a null object as the receiver.
Destroys the given RID.
3D agent that is used in navigation to reach a location while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO (Reciprocal Velocity Obstacles) collision avoidance. The agent needs navigation data to work correctly. By default this node will register to the default navigation map. If this node is a child of a node it will register to the navigation map of the navigation node or the function can be used to set the navigation node directly. is physics safe.
Note: After is used it is required to use the function once every physics frame to update the internal path logic of the NavigationAgent. The returned vector position from this function should be used as the next movement position for the agent's parent Node.
The distance threshold before a path point is considered to be reached. This will allow an agent to not have to hit a path point on the path exactly, but in the area. If this value is set to high the NavigationAgent will skip points on the path which can lead to leaving the navigation mesh. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the next point on each physics frame update.
The distance threshold before the final target point is considered to be reached. This will allow an agent to not have to hit the point of the final target exactly, but only the area. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the final target point on each physics frame update.
The NavigationAgent height offset is subtracted from the y-axis value of any vector path position for this NavigationAgent. The NavigationAgent height offset does not change or influence the navigation mesh or pathfinding query result. Additional navigation maps that use regions with navigation meshes that the developer baked with appropriate agent radius or height values are required to support different-sized agents.
The maximum distance the agent is allowed away from the ideal path to the final location. This can happen due to trying to avoid collisions. When the maximum distance is exceeded, it recalculates the ideal path.
A bitfield determining all navigation map layers the belongs to. On path requests the agent will ignore navmeshes without at least one matching layer.
If true the agent is registered for an RVO avoidance callback on the . When is used and the processing is completed a safe_velocity Vector3 is received with a signal connection to velocity_computed. Avoidance processing with many registered agents has a significant performance cost and should only be enabled on agents that currently require it.
The radius of the avoidance agent. This is the "body" of the avoidance agent and not the avoidance maneuver starting radius (which is controlled by ).
Does not affect normal pathfinding. To change an actor's pathfinding radius bake resources with a different property and use different navigation maps for each actor size.
The distance to search for other agents.
The maximum number of neighbors for the agent to consider.
The minimal amount of time for which this agent's velocities, that are computed with the collision avoidance algorithm, are safe with respect to other agents. The larger the number, the sooner the agent will respond to other agents, but the less freedom in choosing its velocities. Must be positive.
The maximum speed that an agent can move.
Ignores collisions on the Y axis. Must be true to move on a horizontal plane.
Returns the of this agent on the .
Sets the node used by the agent. Useful when you don't want to make the agent a child of a node.
Returns the node that the agent is using for its navigation system.
Sets the of the navigation map this NavigationAgent node should use and also updates the agent on the NavigationServer.
Returns the of the navigation map for this NavigationAgent node. This function returns always the map set on the NavigationAgent node and not the map of the abstract agent on the NavigationServer. If the agent map is changed directly with the NavigationServer API the NavigationAgent node will not be aware of the map change. Use to change the navigation map for the NavigationAgent and also update the agent on the NavigationServer.
Sets the user desired final location. This will clear the current navigation path.
Returns the user-defined target location (set with ).
Returns the next location in global coordinates that can be moved to, making sure that there are no static objects in the way. If the agent does not have a navigation path, it will return the position of the agent's parent. The use of this function once every physics frame is required to update the internal path logic of the NavigationAgent.
Returns the distance to the target location, using the agent's global position. The user must set the target location with in order for this to be accurate.
Sends the passed in velocity to the collision avoidance algorithm. It will adjust the velocity to avoid collisions. Once the adjustment to the velocity is complete, it will emit the velocity_computed signal.
Returns this agent's current path from start to finish in global coordinates. The path only updates when the target location is changed or the agent requires a repath. The path array is not intended to be used in direct path movement as the agent has its own internal path logic that would get corrupted by changing the path array manually. Use the intended once every physics frame to receive the next path point for the agents movement as this function also updates the internal path logic.
Returns which index the agent is currently on in the navigation path's .
Returns true if the target location is reached. The target location is set using . It may not always be possible to reach the target location. It should always be possible to reach the final location though. See .
Returns true if the target location is reachable. The target location is set using .
Returns true if the navigation path's final location has been reached.
Returns the reachable final location in global coordinates. This can change if the navigation path is altered in any way. Because of this, it would be best to check this each frame.
2D agent that is used in navigation to reach a location while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO (Reciprocal Velocity Obstacles) collision avoidance. The agent needs navigation data to work correctly. By default this node will register to the default navigation map. If this node is a child of a node it will register to the navigation map of the navigation node or the function can be used to set the navigation node directly. is physics safe.
Note: After is used it is required to use the function once every physics frame to update the internal path logic of the NavigationAgent. The returned vector position from this function should be used as the next movement position for the agent's parent Node.
The distance threshold before a path point is considered to be reached. This will allow an agent to not have to hit a path point on the path exactly, but in the area. If this value is set to high the NavigationAgent will skip points on the path which can lead to leaving the navigation mesh. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the next point on each physics frame update.
The distance threshold before the final target point is considered to be reached. This will allow an agent to not have to hit the point of the final target exactly, but only the area. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the final target point on each physics frame update.
The maximum distance the agent is allowed away from the ideal path to the final location. This can happen due to trying to avoid collisions. When the maximum distance is exceeded, it recalculates the ideal path.
A bitfield determining all navigation map layers the belongs to. On path requests the agent will ignore navmeshes without at least one matching layer.
If true the agent is registered for an RVO avoidance callback on the . When is used and the processing is completed a safe_velocity Vector2 is received with a signal connection to velocity_computed. Avoidance processing with many registered agents has a significant performance cost and should only be enabled on agents that currently require it.
The radius of the avoidance agent. This is the "body" of the avoidance agent and not the avoidance maneuver starting radius (which is controlled by ).
Does not affect normal pathfinding.
The distance to search for other agents.
The maximum number of neighbors for the agent to consider.
The minimal amount of time for which this agent's velocities, that are computed with the collision avoidance algorithm, are safe with respect to other agents. The larger the number, the sooner the agent will respond to other agents, but the less freedom in choosing its velocities. Must be positive.
The maximum speed that an agent can move.
Returns the of this agent on the .
Sets the node used by the agent. Useful when you don't want to make the agent a child of a node.
Returns the node that the agent is using for its navigation system.
Sets the of the navigation map this NavigationAgent node should use and also updates the agent on the NavigationServer.
Returns the of the navigation map for this NavigationAgent node. This function returns always the map set on the NavigationAgent node and not the map of the abstract agent on the NavigationServer. If the agent map is changed directly with the NavigationServer API the NavigationAgent node will not be aware of the map change. Use to change the navigation map for the NavigationAgent and also update the agent on the NavigationServer.
Sets the user desired final location. This will clear the current navigation path.
Returns the user-defined target location (set with ).
Returns the next location in global coordinates that can be moved to, making sure that there are no static objects in the way. If the agent does not have a navigation path, it will return the position of the agent's parent. The use of this function once every physics frame is required to update the internal path logic of the NavigationAgent.
Returns the distance to the target location, using the agent's global position. The user must set the target location with in order for this to be accurate.
Sends the passed in velocity to the collision avoidance algorithm. It will adjust the velocity to avoid collisions. Once the adjustment to the velocity is complete, it will emit the velocity_computed signal.
Returns this agent's current path from start to finish in global coordinates. The path only updates when the target location is changed or the agent requires a repath. The path array is not intended to be used in direct path movement as the agent has its own internal path logic that would get corrupted by changing the path array manually. Use the intended once every physics frame to receive the next path point for the agents movement as this function also updates the internal path logic.
Returns which index the agent is currently on in the navigation path's .
Returns true if the target location is reached. The target location is set using . It may not always be possible to reach the target location. It should always be possible to reach the final location though. See .
Returns true if the target location is reachable. The target location is set using .
Returns true if the navigation path's final location has been reached.
Returns the reachable final location in global coordinates. This can change if the navigation path is altered in any way. Because of this, it would be best to check this each frame.
A navigation mesh is a collection of polygons that define which areas of an environment are traversable to aid agents in pathfinding through complicated spaces.
Parses mesh instances as geometry. This includes , , and nodes.
Parses colliders as geometry. The collider should be in any of the layers specified by .
Both and .
Represents the size of the enum.
Watershed partitioning. Generally the best choice if you precompute the navigation mesh, use this if you have large open areas.
Monotone partitioning. Use this if you want fast navigation mesh generation.
Layer partitioning. Good choice to use for tiled navigation mesh with medium and small sized tiles.
Represents the size of the enum.
Scans the child nodes of recursively for geometry.
Scans nodes in a group and their child nodes recursively for geometry. The group is specified by .
Uses nodes in a group for geometry. The group is specified by .
Represents the size of the enum.
Partitioning algorithm for creating the navigation mesh polys. See for possible values.
Determines which type of nodes will be parsed as geometry. See for possible values.
The physics layers to scan for static colliders.
Only used when is or .
The source of the geometry used when baking. See for possible values.
The name of the group to scan for geometry.
Only used when is or .
The XZ plane cell size to use for fields.
The Y axis cell size to use for fields.
The minimum floor to ceiling height that will still allow the floor area to be considered walkable.
Note: While baking, this value will be rounded up to the nearest multiple of .
The distance to erode/shrink the walkable area of the heightfield away from obstructions.
Note: While baking, this value will be rounded up to the nearest multiple of .
The minimum ledge height that is considered to still be traversable.
Note: While baking, this value will be rounded down to the nearest multiple of .
The maximum slope that is considered walkable, in degrees.
The minimum size of a region for it to be created.
Note: This value will be squared to calculate the minimum number of cells allowed to form isolated island areas. For example, a value of 8 will set the number of cells to 64.
Any regions with a size smaller than this will be merged with larger regions if possible.
Note: This value will be squared to calculate the number of cells. For example, a value of 20 will set the number of cells to 400.
The maximum allowed length for contour edges along the border of the mesh.
Note: While baking, this value will be rounded up to the nearest multiple of .
The maximum distance a simplfied contour's border edges should deviate the original raw contour.
The maximum number of vertices allowed for polygons generated during the contour to polygon conversion process.
The sampling distance to use when generating the detail mesh, in cell unit.
The maximum distance the detail mesh surface should deviate from heightfield, in cell unit.
If true, marks non-walkable spans as walkable if their maximum is within of a walkable neighbor.
If true, marks spans that are ledges as non-walkable.
If true, marks walkable spans as not walkable if the clearance above the span is less than .
If the baking has a volume the navigation mesh baking will be restricted to its enclosing area.
The position offset applied to the .
If value is true, sets the specified bit in the .
If value is false, clears the specified bit in the .
Returns whether the specified bit of the is set.
Sets the vertices that can be then indexed to create polygons with the method.
Returns a containing all the vertices being used to create the polygons.
Adds a polygon using the indices of the vertices you get when calling .
Returns the number of polygons in the navigation mesh.
Returns a containing the indices of the vertices of a created polygon.
Clears the array of polygons, but it doesn't clear the array of vertices.
Initializes the navigation mesh by setting the vertices and indices according to a .
This class is responsible for creating and clearing 3D navigation meshes used as resources inside . The has very limited to no use for 2D as the navigation mesh baking process expects 3D node types and 3D source geometry to parse.
The entire navigation mesh baking is best done in a separate thread as the voxelization, collision tests and mesh optimization steps involved are very performance and time hungry operations.
Navigation mesh baking happens in multiple steps and the result depends on 3D source geometry and properties of the resource. In the first step, starting from a root node and depending on properties all valid 3D source geometry nodes are collected from the . Second, all collected nodes are parsed for their relevant 3D geometry data and a combined 3D mesh is build. Due to the many different types of parsable objects, from normal s to s or various s, some operations to collect geometry data can trigger and synchronizations. Server synchronization can have a negative effect on baking time or framerate as it often involves locking for thread security. Many parsable objects and the continuous synchronization with other threaded Servers can increase the baking time significantly. On the other hand only a few but very large and complex objects will take some time to prepare for the Servers which can noticeably stall the next frame render. As a general rule the total amount of parsable objects and their individual size and complexity should be balanced to avoid framerate issues or very long baking times. The combined mesh is then passed to the Recast Navigation Object to test the source geometry for walkable terrain suitable to agent properties by creating a voxel world around the meshes bounding area.
The finalized navigation mesh is then returned and stored inside the for use as a resource inside nodes.
Note: Using meshes to not only define walkable surfaces but also obstruct navigation baking does not always work. The navigation baking has no concept of what is a geometry "inside" when dealing with mesh source geometry and this is intentional. Depending on current baking parameters, as soon as the obstructing mesh is large enough to fit a navigation mesh area inside, the baking will generate navigation mesh areas that are inside the obstructing source geometry mesh.
Bakes navigation data to the provided nav_mesh by parsing child nodes under the provided root_node or a specific group of nodes for potential source geometry. The parse behavior can be controlled with the and properties on the resource.
Removes all polygons and vertices from the provided nav_mesh resource.
An instance of a . It tells the node what can be navigated and what cannot, based on the resource.
By default this node will register to the default navigation map. If this node is a child of a node it will register to the navigation map of the navigation node.
Two regions can be connected to each other if they share a similar edge. You can set the minimum distance between two vertices required to connect two edges by using .
Note: Overlapping two regions' navmeshes is not enough for connecting two regions. They must share a similar edge.
The cost of entering this region from another region can be controlled with the value.
Note: This value is not added to the path cost when the start position is already inside this region.
The cost of traveling distances inside this region can be controlled with the multiplier.
The resource to use.
Determines if the is enabled or disabled.
A bitfield determining all navigation map layers the belongs to. On path requests with navmeshes without matching layers will be ignored and the navigation map will only proximity merge different navmeshes with matching layers.
When pathfinding enters this region's navmesh from another regions navmesh the enter_cost value is added to the path distance for determining the shortest path.
When pathfinding moves inside this region's navmesh the traveled distances are multiplied with travel_cost for determining the shortest path.
Returns the of this region on the . Combined with can be used to identify the closest to a point on the merged navigation map.
Bakes the . If on_thread is set to true (default), the baking is done on a separate thread. Baking on separate thread is useful because navigation baking is not a cheap operation. When it is completed, it automatically sets the new . Please note that baking on separate thread may be very slow if geometry is parsed from meshes as async access to each mesh involves heavy synchronization. Also, please note that baking on a separate thread is automatically disabled on operating systems that cannot use threads (such as HTML5 with threads disabled).
3D obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. This can be done by having the obstacle as a child of a node, or using . is physics safe.
Note: Obstacles are intended as a last resort option for constantly moving objects that cannot be (re)baked to a navigation mesh efficiently.
Enables radius estimation algorithm which uses parent's collision shapes to determine the obstacle radius.
The radius of the agent. Used only if is set to false.
Returns the of this obstacle on the .
Sets the node used by the obstacle. Useful when you don't want to make the obstacle a child of a node.
Returns the node that the obstacle is using for its navigation system.
2D obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. This can be done by having the obstacle as a child of a node, or using . is physics safe.
Note: Obstacles are intended as a last resort option for constantly moving objects that cannot be (re)baked to a navigation mesh efficiently.
Enables radius estimation algorithm which uses parent's collision shapes to determine the obstacle radius.
The radius of the agent. Used only if is set to false.
Returns the of this obstacle on the .
Sets the node used by the obstacle. Useful when you don't want to make the obstacle a child of a node.
Returns the node that the obstacle is using for its navigation system.
There are two ways to create polygons. Either by using the method, or using the method.
Using :
var polygon = NavigationPolygon.new()
var outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
polygon.add_outline(outline)
polygon.make_polygons_from_outlines()
$NavigationPolygonInstance.navpoly = polygon
Using and indices of the vertices array.
var polygon = NavigationPolygon.new()
var vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
polygon.set_vertices(vertices)
var indices = PoolIntArray([0, 1, 2, 3])
polygon.add_polygon(indices)
$NavigationPolygonInstance.navpoly = polygon
Sets the vertices that can be then indexed to create polygons with the method.
Returns a containing all the vertices being used to create the polygons.
Adds a polygon using the indices of the vertices you get when calling .
Returns the count of all polygons.
Returns a containing the indices of the vertices of a created polygon.
Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
Returns the resulting from this navigation polygon. This navmesh can be used to update the navmesh of a region with the API directly (as 2D uses the 3D server behind the scene).
Appends a that contains the vertices of an outline to the internal array that contains all the outlines. You have to call in order for this array to be converted to polygons that the engine will use.
Adds a that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call in order for this array to be converted to polygons that the engine will use.
Returns the number of outlines that were created in the editor or by script.
Changes an outline created in the editor or by script. You have to call for the polygons to update.
Returns a containing the vertices of an outline that was created in the editor or by script.
Removes an outline created in the editor or by script. You have to call for the polygons to update.
Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
Creates polygons from the outlines added in the editor or by script.
A region of the navigation map. It tells the what can be navigated and what cannot, based on its resource.
By default this node will register to the default navigation map. If this node is a child of a node it will register to the navigation map of the navigation node.
Two regions can be connected to each other if they share a similar edge. You can set the minimum distance between two vertices required to connect two edges by using .
Note: Overlapping two regions' polygons is not enough for connecting two regions. They must share a similar edge.
The pathfinding cost of entering this region from another region can be controlled with the value.
Note: This value is not added to the path cost when the start position is already inside this region.
The pathfinding cost of traveling distances inside this region can be controlled with the multiplier.
The resource to use.
Determines if the is enabled or disabled.
A bitfield determining all navigation map layers the belongs to. On path requests with navmeshes without matching layers will be ignored and the navigation map will only proximity merge different navmeshes with matching layers.
When pathfinding enters this region's navmesh from another regions navmesh the enter_cost value is added to the path distance for determining the shortest path.
When pathfinding moves inside this region's navmesh the traveled distances are multiplied with travel_cost for determining the shortest path.
Returns the of this region on the . Combined with can be used to identify the closest to a point on the merged navigation map.
NavigationServer is the server responsible for all 3D navigation. It handles several objects, namely maps, regions and agents.
Maps are made up of regions, which are made of navigation meshes. Together, they define the navigable areas in the 3D world.
Note: Most NavigationServer changes take effect after the next physics frame and not immediately. This includes all changes made to maps, regions or agents by navigation related Nodes in the SceneTree or made through scripts.
For two regions to be connected to each other, they must share a similar edge. An edge is considered connected to another if both of its two vertices are at a distance less than to the respective other edge's vertex.
To use the collision avoidance system, you may use agents. You can set an agent's target velocity, then the servers will emit a callback with a modified velocity.
Note: The collision avoidance system ignores regions. Using the modified velocity as-is might lead to pushing and agent outside of a navigable area. This is a limitation of the collision avoidance system, any more complex situation may require the use of the physics engine.
This server keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying.
Returns all created navigation map s on the NavigationServer. This returns both 2D and 3D created navigation maps as there is technically no distinction between them.
Create a new map.
Sets the map active.
Returns true if the map is active.
Sets the map up direction.
Returns the map's up direction.
Set the map cell size used to weld the navigation mesh polygons.
Returns the map cell size.
Set the map cell height used to weld the navigation mesh polygons.
Returns the map cell height.
Set the map edge connection margin used to weld the compatible region edges.
Returns the edge connection margin of the map. This distance is the minimum vertex distance needed to connect two edges from different regions.
Returns the navigation path to reach the destination from the origin. navigation_layers is a bitmask of all region layers that are allowed to be in the path.
Returns the closest point between the navigation surface and the segment.
Returns the point closest to the provided to_point on the navigation mesh surface.
Returns the normal for the point returned by .
Returns the owner region RID for the point returned by .
Returns all navigation regions s that are currently assigned to the requested navigation map.
Returns all navigation agents s that are currently assigned to the requested navigation map.
This function immediately forces synchronization of the specified navigation map . By default navigation maps are only synchronized at the end of each physics frame. This function can be used to immediately (re)calculate all the navigation meshes and region connections of the navigation map. This makes it possible to query a navigation path for a changed map immediately and in the same frame (multiple times if needed).
Due to technical restrictions the current NavigationServer command queue will be flushed. This means all already queued update commands for this physics frame will be executed, even those intended for other maps, regions and agents not part of the specified map. The expensive computation of the navigation meshes and region connections of a map will only be done for the specified map. Other maps will receive the normal synchronization at the end of the physics frame. Should the specified map receive changes after the forced update it will update again as well when the other maps receive their update.
Avoidance processing and dispatch of the safe_velocity signals is untouched by this function and continues to happen for all maps and agents at the end of the physics frame.
Note: With great power comes great responsibility. This function should only be used by users that really know what they are doing and have a good reason for it. Forcing an immediate update of a navigation map requires locking the NavigationServer and flushing the entire NavigationServer command queue. Not only can this severely impact the performance of a game but it can also introduce bugs if used inappropriately without much foresight.
Creates a new region.
Sets the enter_cost for this region.
Returns the enter_cost of this region.
Sets the travel_cost for this region.
Returns the travel_cost of this region.
Returns true if the provided point in world space is currently owned by the provided navigation region. Owned in this context means that one of the region's navigation mesh polygon faces has a possible position at the closest distance to this point compared to all other navigation meshes from other navigation regions that are also registered on the navigation map of the provided region.
If multiple navigation meshes have positions at equal distance the navigation region whose polygons are processed first wins the ownership. Polygons are processed in the same order that navigation regions were registered on the NavigationServer.
Note: If navigation meshes from different navigation regions overlap (which should be avoided in general) the result might not be what is expected.
Sets the map for the region.
Returns the navigation map the requested region is currently assigned to.
Set the region's navigation layers. This allows selecting regions from a path request (when using ).
Returns the region's navigation layers.
Sets the global transformation for the region.
Sets the navigation mesh for the region.
Bakes the navigation mesh.
Returns how many connections this region has with other regions in the map.
Returns the starting point of a connection door. connection is an index between 0 and the return value of .
Returns the ending point of a connection door. connection is an index between 0 and the return value of .
Creates the agent.
Puts the agent in the map.
Returns the navigation map the requested agent is currently assigned to.
Sets the maximum distance to other agents this agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe.
Sets the maximum number of other agents the agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe.
The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to other agents. The larger this number, the sooner this agent will respond to the presence of other agents, but the less freedom this agent has in choosing its velocities. Must be positive.
Sets the radius of the agent.
Sets the maximum speed of the agent. Must be positive.
Sets the current velocity of the agent.
Sets the new target velocity.
Sets the position of the agent in world space.
Returns true if the map got changed the previous frame.
Callback called at the end of the RVO process. If a callback is created manually and the agent is placed on a navigation map it will calculate avoidance for the agent and dispatch the calculated safe_velocity to the receiver object with a signal to the chosen method name.
Note: Created callbacks are always processed independently of the SceneTree state as long as the agent is on a navigation map and not freed. To disable the dispatch of a callback from an agent use again with a null object as the receiver.
Destroys the given RID.
Control activation of this server.
Process the collision avoidance agents.
The result of this process is needed by the physics server, so this must be called in the main thread.
Note: This function is not thread safe.
A implementation that can be used as a and controlled from a script.
Its purpose is to allow adding a new backend for the high-Level multiplayer API without needing to use GDNative.
Initialize the peer with the given peer_id (must be between 1 and 2147483647).
Can only be called if the connection status is . See .
Set the max packet size that this peer can handle.
Set the state of the connection. See .
This will emit the NetworkedMultiplayerPeer.connection_succeeded, NetworkedMultiplayerPeer.connection_failed or NetworkedMultiplayerPeer.server_disconnected signals depending on the status and if the peer has the unique network id of 1.
You can only change to from and to from .
Deliver a packet to the local .
When your script receives a packet from other peers over the network (originating from the packet_generated signal on the sending peer), passing it to this method will deliver it locally.
A PacketPeer implementation that should be passed to after being initialized as either a client or server. Events can then be handled by connecting to signals.
ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol).
Note: ENet only uses UDP, not TCP. When forwarding the server port to make your server accessible on the public Internet, you only need to forward the server port in UDP. You can use the class to try to forward the server port automatically when starting the server.
No compression. This uses the most bandwidth, but has the upside of requiring the fewest CPU resources. This option may also be used to make network debugging using tools like Wireshark easier.
ENet's built-in range encoding. Works well on small packets, but is not the most efficient algorithm on packets larger than 4 KB.
FastLZ compression. This option uses less CPU resources compared to , at the expense of using more bandwidth.
Zlib compression. This option uses less bandwidth compared to , at the expense of using more CPU resources. Note that this algorithm is not very efficient on packets smaller than 4 KB. Therefore, it's recommended to use other compression algorithms in most cases.
Zstandard compression.
The compression method used for network packets. These have different tradeoffs of compression speed versus bandwidth, you may need to test which one works best for your use case if you use compression at all.
Note: Most games' network design involve sending many small packets frequently (smaller than 4 KB each). If in doubt, it is recommended to keep the default compression algorithm as it works best on these small packets.
Note: must be set to the same value on both the server and all its clients. Clients will fail to connect if the set on the client differs from the one set on the server. Prior to Godot 3.4, the default was . Nonetheless, mixing engine versions between clients and server is not recommended and not officially supported.
Set the default channel to be used to transfer data. By default, this value is -1 which means that ENet will only use 2 channels: one for reliable packets, and one for unreliable packets. The channel 0 is reserved and cannot be used. Setting this member to any value between 0 and (excluded) will force ENet to use that channel for sending data. See for more information about ENet channels.
The number of channels to be used by ENet. Channels are used to separate different kinds of data. In reliable or ordered mode, for example, the packet delivery order is ensured on a per-channel basis. This is done to combat latency and reduces ordering restrictions on packets. The delivery status of a packet in one channel won't stall the delivery of other packets in another channel.
Enforce ordered packets when using (thus behaving similarly to ). This is the only way to use ordering with the RPC system.
Enable or disable the server feature that notifies clients of other peers' connection/disconnection, and relays messages between them. When this option is false, clients won't be automatically notified of other peers and won't be able to send them packets through the server.
Enable or disable certificate verification when is true.
The hostname used for DTLS verification, to be compared against the "CN" value in the certificate provided by the server.
When set to an empty string, the address parameter passed to is used instead.
When enabled, the client or server created by this peer, will use instead of raw UDP sockets for communicating with the remote peer. This will make the communication encrypted with DTLS at the cost of higher resource usage and potentially larger packet size.
Note: When creating a DTLS server, make sure you setup the key/certificate pair via and . For DTLS clients, have a look at the option, and configure the certificate accordingly via .
Create server that listens to connections via port. The port needs to be an available, unused port between 0 and 65535. Note that ports below 1024 are privileged and may require elevated permissions depending on the platform. To change the interface the server listens on, use . The default IP is the wildcard "*", which listens on all available interfaces. max_clients is the maximum number of clients that are allowed at once, any number up to 4095 may be used, although the achievable number of simultaneous clients may be far lower and depends on the application. For additional details on the bandwidth parameters, see . Returns OK if a server was created, ERR_ALREADY_IN_USE if this NetworkedMultiplayerENet instance already has an open connection (in which case you need to call first) or ERR_CANT_CREATE if the server could not be created.
Create client that connects to a server at address using specified port. The given address needs to be either a fully qualified domain name (e.g. "www.example.com") or an IP address in IPv4 or IPv6 format (e.g. "192.168.1.1"). The port is the port the server is listening on. The in_bandwidth and out_bandwidth parameters can be used to limit the incoming and outgoing bandwidth to the given number of bytes per second. The default of 0 means unlimited bandwidth. Note that ENet will strategically drop packets on specific sides of a connection between peers to ensure the peer's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. Returns OK if a client was created, ERR_ALREADY_IN_USE if this NetworkedMultiplayerENet instance already has an open connection (in which case you need to call first) or ERR_CANT_CREATE if the client could not be created. If client_port is specified, the client will also listen to the given port; this is useful for some NAT traversal techniques.
Closes the connection. Ignored if no connection is currently established. If this is a server it tries to notify all clients before forcibly disconnecting them. If this is a client it simply closes the connection to the server.
Disconnect the given peer. If "now" is set to true, the connection will be closed immediately without flushing queued messages.
The IP used when creating a server. This is set to the wildcard "*" by default, which binds to all available interfaces. The given IP needs to be in IPv4 or IPv6 address format, for example: "192.168.1.1".
Configure the to use when is true. Remember to also call to setup your .
Configure the to use when is true. For servers, you must also setup the via .
Returns the IP address of the given peer.
Returns the remote port of the given peer.
Sets the timeout parameters for a peer.The timeout parameters control how and when a peer will timeout from a failure to acknowledge reliable traffic. Timeout values are expressed in milliseconds.
The timeout_limit is a factor that, multiplied by a value based on the average round trip time, will determine the timeout limit for a reliable packet. When that limit is reached, the timeout will be doubled, and the peer will be disconnected if that limit has reached timeout_min. The timeout_max parameter, on the other hand, defines a fixed timeout for which any packet must be acknowledged or the peer will be dropped.
Returns the channel of the next packet that will be retrieved via .
Returns the channel of the last packet fetched via .
Manages the connection to network peers. Assigns unique IDs to each client connected to the server. See also .
Note: The high-level multiplayer API protocol is an implementation detail and isn't meant to be used by non-Godot servers. It may change without notice.
Packets are sent to the server and then redistributed to other peers.
Packets are sent to the server alone.
The ongoing connection disconnected.
A connection attempt is ongoing.
The connection attempt succeeded.
Packets are not acknowledged, no resend attempts are made for lost packets. Packets may arrive in any order. Potentially faster than . Use for non-critical data, and always consider whether the order matters.
Packets are not acknowledged, no resend attempts are made for lost packets. Packets are received in the order they were sent in. Potentially faster than . Use for non-critical data or data that would be outdated if received late due to resend attempt(s) anyway, for example movement and positional data.
Packets must be received and resend attempts should be made until the packets are acknowledged. Packets must be received in the order they were sent in. Most reliable transfer mode, but potentially the slowest due to the overhead. Use for critical data that must be transmitted and arrive in order, for example an ability being triggered or a chat message. Consider carefully if the information really is critical, and use sparingly.
If true, this refuses new connections.
The manner in which to send packets to the target_peer. See .
Sets the peer to which packets will be sent.
The id can be one of: to send to all connected peers, to send to the peer acting as server, a valid peer ID to send to that specific peer, a negative peer ID to send to all peers except that one. By default, the target peer is .
Returns the ID of the who sent the most recent packet.
Waits up to 1 second to receive a new network event.
Returns the current state of the connection. See .
Returns the ID of this .
Also known as 9-slice panels, NinePatchRect produces clean panels of any size, based on a small texture. To do so, it splits the texture in a 3×3 grid. When you scale the node, it tiles the texture's sides horizontally or vertically, the center on both axes but it doesn't scale or tile the corners.
Stretches the center texture across the NinePatchRect. This may cause the texture to be distorted.
Repeats the center texture across the NinePatchRect. This won't cause any visible distortion. The texture must be seamless for this to work without displaying artifacts between edges.
Note: Only supported when using the GLES3 renderer. When using the GLES2 renderer, this will behave like .
Repeats the center texture across the NinePatchRect, but will also stretch the texture to make sure each tile is visible in full. This may cause the texture to be distorted, but less than . The texture must be seamless for this to work without displaying artifacts between edges.
Note: Only supported when using the GLES3 renderer. When using the GLES2 renderer, this will behave like .
The node's texture resource.
If true, draw the panel's center. Else, only draw the 9-slice's borders.
Rectangular region of the texture to sample from. If you're working with an atlas, use this property to define the area the 9-slice should use. All other properties are relative to this one. If the rect is empty, NinePatchRect will use the whole texture.
The width of the 9-slice's left column. A margin of 16 means the 9-slice's left corners and side will have a width of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
The height of the 9-slice's top row. A margin of 16 means the 9-slice's top corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
The width of the 9-slice's right column. A margin of 16 means the 9-slice's right corners and side will have a width of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
The height of the 9-slice's bottom row. A margin of 16 means the 9-slice's bottom corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
The stretch mode to use for horizontal stretching/tiling. See for possible values.
The stretch mode to use for vertical stretching/tiling. See for possible values.
Sets the size of the margin identified by the given constant to value in pixels.
Returns the size of the margin identified by the given constant.
A 2D game object, with a transform (position, rotation, and scale). All 2D nodes, including physics objects and sprites, inherit from Node2D. Use Node2D as a parent node to move, scale and rotate children in a 2D project. Also gives control of the node's render order.
Position, relative to the node's parent.
Rotation in radians, relative to the node's parent.
Rotation in degrees, relative to the node's parent.
The node's scale. Unscaled value: (1, 1).
Note: Negative X scales in 2D are not decomposable from the transformation matrix. Due to the way scale is represented with transformation matrices in Godot, negative scales on the X axis will be changed to negative scales on the Y axis and a rotation of 180 degrees when decomposed.
Local .
Global position.
Global rotation in radians.
Global rotation in degrees.
Global scale.
Global .
Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others. Must be between and (inclusive).
If true, the node's Z index is relative to its parent's Z index. If this node's Z index is 2 and its parent's effective Z index is 3, then this node's effective Z index will be 2 + 3 = 5.
Applies a rotation to the node, in radians, starting from its current rotation.
Applies a local translation on the node's X axis based on the 's delta. If scaled is false, normalizes the movement.
Applies a local translation on the node's Y axis based on the 's delta. If scaled is false, normalizes the movement.
Translates the node by the given offset in local coordinates.
Adds the offset vector to the node's global position.
Multiplies the current scale by the ratio vector.
Rotates the node so it points towards the point, which is expected to use global coordinates.
Returns the angle between the node and the point in radians.
Illustration of the returned angle.
Transforms the provided global position into a position in local coordinate space. The output will be local relative to the it is called on. e.g. It is appropriate for determining the positions of child nodes, but it is not appropriate for determining its own position relative to its parent.
Transforms the provided local position into a position in global coordinate space. The input is expected to be local relative to the it is called on. e.g. Applying this method to the positions of child nodes will correctly transform their positions into the global coordinate space, but applying it to a node's own position will give an incorrect result, as it will incorporate the node's own transformation into its global position.
Returns the relative to this node's parent.
Uses an to fill the texture data. You can specify the texture size but keep in mind that larger textures will take longer to generate and seamless noise only works with square sized textures.
NoiseTexture can also generate normalmap textures.
The class uses s to generate the texture data internally, so may return null if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the data:
var texture = preload("res://noise.tres")
yield(texture, "changed")
var image = texture.get_data()
Width of the generated texture.
Height of the generated texture.
Whether the texture can be tiled without visible seams or not. Seamless textures take longer to generate.
Note: Seamless noise has a lower contrast compared to non-seamless noise. This is due to the way noise uses higher dimensions for generating seamless noise.
If true, the resulting texture contains a normal map created from the original noise interpreted as a bump map.
Strength of the bump maps used in this texture. A higher value will make the bump maps appear larger while a lower value will make them appear softer.
The instance used to generate the noise.
An offset used to specify the noise space coordinate of the top left corner of the generated noise. This value is ignored if is enabled.
s that are placed within your scene will automatically cull objects that are hidden from view by the occluder. This can increase performance by decreasing the amount of objects drawn.
s are totally dynamic, you can move them as you wish. This means you can for example, place occluders on a moving spaceship, and have it occlude objects as it flies past.
You can place a large number of s within a scene. As it would be counterproductive to cull against hundreds of occluders, the system will automatically choose a selection of these for active use during any given frame, based a screen space metric. Larger occluders are favored, as well as those close to the camera. Note that a small occluder close to the camera may be a better occluder in terms of screen space than a large occluder far in the distance.
The type of occlusion primitive is determined by the that you add to the . Some s may allow more than one primitive in a single, node, for greater efficiency.
Although s work in general use, they also become even more powerful when used in conjunction with the portal system. Occluders are placed in rooms (based on their origin), and can block portals (and thus entire rooms) as well as objects from rendering.
Editor facility that helps you draw a 2D polygon used as resource for .
Culling is disabled. See .
Culling is performed in the clockwise direction. See .
Culling is performed in the counterclockwise direction. See .
If true, closes the polygon. A closed OccluderPolygon2D occludes the light coming from any direction. An opened OccluderPolygon2D occludes the light only at its outline's direction.
The culling mode to use.
A array with the index for polygon's vertices positions.
Note: The returned value is a copy of the underlying array, rather than a reference.
s can use any primitive shape derived from .
s are resources used by nodes, allowing geometric occlusion culling.
The polygon must be a convex polygon. The polygon points can be created and deleted either in the Editor inspector or by calling set_polygon_points. The points of the edges can be set by dragging the handles in the Editor viewport.
Additionally each polygon occluder can optionally support a single hole. If you add at least three points in the Editor inspector to the hole, you can drag the edge points of the hole in the Editor viewport.
In general, the lower the number of edges in polygons and holes, the faster the system will operate at runtime, so in most cases you will want to use 4 points for each.
Specifies whether the occluder should operate from both sides. If false, the occluder will operate one way only.
Allows changing the polygon geometry from code.
Allows changing the hole geometry from code.
Sets an individual polygon point position.
Sets an individual hole point position.
s are resources used by nodes, allowing geometric occlusion culling.
This shape can include multiple spheres. These can be created and deleted either in the Editor inspector or by calling set_spheres. The sphere positions can be set by dragging the handle in the Editor viewport. The radius can be set with the smaller handle.
The sphere data can be accessed as an array of s. The position of each sphere is stored in the normal, and the radius is stored in the d value of the plane.
Sets an individual sphere's position.
Sets an individual sphere's radius.
An Omnidirectional light is a type of that emits light in all directions. The light is attenuated by distance and this attenuation can be configured by changing its energy, radius, and attenuation parameters.
Note: By default, only 32 OmniLights may affect a single mesh resource at once. Consider splitting your level into several meshes to decrease the likelihood that more than 32 lights will affect the same mesh resource. Splitting the level mesh will also improve frustum culling effectiveness, leading to greater performance. If you need to use more lights per mesh, you can increase at the cost of shader compilation times.
Shadows are rendered to a dual-paraboloid texture. Faster than , but lower-quality.
Shadows are rendered to a cubemap. Slower than , but higher-quality. Only supported on GPUs that feature support for depth cubemaps.
Use more detail vertically when computing the shadow.
Use more detail horizontally when computing the shadow.
The light's radius. Note that the effectively lit area may appear to be smaller depending on the in use. No matter the in use, the light will never reach anything outside this radius.
The light's attenuation (drop-off) curve. A number of presets are available in the Inspector by right-clicking the curve.
The shadow rendering mode to use for this . See .
Note: In GLES2, is only supported on GPUs that feature support for depth cubemaps. Old GPUs such as the Radeon HD 4000 series don't support cubemap shadows and will fall back to dual paraboloid shadows as a result.
See .
This resource allows you to configure and sample a fractal noise space. Here is a brief usage example that configures an OpenSimplexNoise and gets samples at various positions and dimensions:
var noise = OpenSimplexNoise.new()
# Configure
noise.seed = randi()
noise.octaves = 4
noise.period = 20.0
noise.persistence = 0.8
# Sample
print("Values:")
print(noise.get_noise_2d(1.0, 1.0))
print(noise.get_noise_3d(0.5, 3.0, 15.0))
print(noise.get_noise_4d(0.5, 1.9, 4.7, 0.0))
Seed used to generate random values, different seeds will generate different noise maps.
Number of OpenSimplex noise layers that are sampled to get the fractal noise. Higher values result in more detailed noise but take more time to generate.
Note: The maximum allowed value is 9.
Period of the base octave. A lower period results in a higher-frequency noise (more value changes across the same distance).
Contribution factor of the different octaves. A persistence value of 1 means all the octaves have the same contribution, a value of 0.5 means each octave contributes half as much as the previous one.
Difference in period between .
Generate a noise image in format with the requested width and height, based on the current noise parameters. If noise_offset is specified, then the offset value is used as the coordinates of the top-left corner of the generated noise.
If the parameter is null, then the default value is new Vector2(0, 0)
Generate a tileable noise image in format, based on the current noise parameters. Generated seamless images are always square (size × size).
Note: Seamless noise has a lower contrast compared to non-seamless noise. This is due to the way noise uses higher dimensions for generating seamless noise.
Returns the 1D noise value [-1,1] at the given x-coordinate.
Note: This method actually returns the 2D noise value [-1,1] with fixed y-coordinate value 0.0.
Returns the 2D noise value [-1,1] at the given position.
Returns the 3D noise value [-1,1] at the given position.
Returns the 4D noise value [-1,1] at the given position.
Returns the 2D noise value [-1,1] at the given position.
Returns the 3D noise value [-1,1] at the given position.
OptionButton is a type button that provides a selectable list of items when pressed. The item selected becomes the "current" item and is displayed as the button text.
See also which contains common properties and methods associated with this node.
The index of the currently selected item, or -1 if no item is selected.
Adds an item, with text label and (optionally) id. If no id is passed, the item index will be used as the item's ID. New items are appended at the end.
Adds an item, with a texture icon, text label and (optionally) id. If no id is passed, the item index will be used as the item's ID. New items are appended at the end.
Sets the text of the item at index idx.
Sets the icon of the item at index idx.
Sets whether the item at index idx is disabled.
Disabled items are drawn differently in the dropdown and are not selectable by the user. If the current selected item is set as disabled, it will remain selected.
Sets the ID of the item at index idx.
Sets the metadata of an item. Metadata may be of any type and can be used to store extra information about an item, such as an external string ID.
Sets the tooltip of the item at index idx.
Returns the text of the item at index idx.
Returns the icon of the item at index idx.
Returns the ID of the item at index idx.
Returns the index of the item with the given id.
Retrieves the metadata of an item. Metadata may be any type and can be used to store extra information about an item, such as an external string ID.
Returns the tooltip of the item at index idx.
Returns true if the item at index idx is disabled.
Returns the amount of items in the OptionButton, including separators.
Adds a separator to the list of items. Separators help to group items. Separator also takes up an index and is appended at the end.
Clears all the items in the .
Selects an item by index and makes it the current item. This will work even if the item is disabled.
Passing -1 as the index deselects any currently selected item.
Returns the ID of the selected item, or -1 if no item is selected.
Gets the metadata of the selected item. Metadata for items can be set using .
Removes the item at index idx.
Returns the contained in this button.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
The is used to create packages that can be loaded into a running project using .
var packer = PCKPacker.new()
packer.pck_start("test.pck")
packer.add_file("res://text.txt", "text.txt")
packer.flush()
The above creates package test.pck, then adds a file named text.txt at the root of the package.
Creates a new PCK file with the name pck_name. The .pck file extension isn't added automatically, so it should be part of pck_name (even though it's not required).
Adds the source_path file to the current PCK package at the pck_path internal path (should start with res://).
Writes the files specified using all calls since the last flush. If verbose is true, a list of files added will be printed to the console for easier debugging.
Optimized translation. Uses real-time compressed translations, which results in very small dictionaries.
Generates and sets an optimized translation from the given resource.
Note: This class is only compiled in editor builds. Run-time glTF loading and saving is not available in exported projects. References to within a script will cause an error in an exported project.
PacketPeer is an abstraction and base class for packet-based protocols (such as UDP). It provides an API for sending and receiving packets both as raw data or variables. This makes it easy to transfer data over a protocol, without having to encode data as low-level bytes or having to worry about network ordering.
Maximum buffer size allowed when encoding Variants. Raise this value to support heavier memory allocations.
The method allocates memory on the stack, and the buffer used will grow automatically to the closest power of two to match the size of the Variant. If the Variant is bigger than encode_buffer_max_size, the method will error out with ERR_OUT_OF_MEMORY.
Deprecated. Use get_var and put_var parameters instead.
If true, the PacketPeer will allow encoding and decoding of object via and .
Warning: Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
Gets a Variant. If allow_objects (or ) is true, decoding objects is allowed.
Warning: Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
Sends a Variant as a packet. If full_objects (or ) is true, encoding objects is allowed (and can potentially include code).
Gets a raw packet.
Sends a raw packet.
Returns the error state of the last packet received (via and ).
Returns the number of packets currently available in the ring-buffer.
This class represents a DTLS peer connection. It can be used to connect to a DTLS server, and is returned by .
Warning: SSL/TLS certificate revocation and certificate pinning are currently not supported. Revoked certificates are accepted as long as they are otherwise valid. If this is a concern, you may want to use automatically managed certificates with a short validity period.
A status representing a that is disconnected.
A status representing a that is currently performing the handshake with a remote peer.
A status representing a that is connected to a remote peer.
A status representing a in a generic error state.
An error status that shows a mismatch in the DTLS certificate domain presented by the host and the domain requested for validation.
Poll the connection to check for incoming packets. Call this frequently to update the status and keep the connection working.
Connects a peer beginning the DTLS handshake using the underlying which must be connected (see ). If validate_certs is true, will validate that the certificate presented by the remote peer and match it with the for_hostname argument. You can specify a custom to use for validation via the valid_certificate argument.
Returns the status of the connection. See for values.
Disconnects this peer, terminating the DTLS session.
PacketStreamPeer provides a wrapper for working using packets over a stream. This allows for using packet based code with StreamPeers. PacketPeerStream implements a custom protocol over the StreamPeer, so the user should not read or write to the wrapped StreamPeer directly.
The wrapped object.
UDP packet peer. Can be used to send raw UDP packets as well as Variants.
Makes this listen on the port binding to bind_address with a buffer size recv_buf_size.
If bind_address is set to "*" (default), the peer will listen on all available addresses (both IPv4 and IPv6).
If bind_address is set to "0.0.0.0" (for IPv4) or "::" (for IPv6), the peer will listen on all available addresses matching that IP type.
If bind_address is set to any valid address (e.g. "192.168.1.101", "::1", etc), the peer will only listen on the interface with that addresses (or fail if no interface with the given address exists).
Closes the UDP socket the is currently listening on.
Waits for a packet to arrive on the listening port. See .
Note: can't be interrupted once it has been called. This can be worked around by allowing the other party to send a specific "death pill" packet like this:
# Server
socket.set_dest_address("127.0.0.1", 789)
socket.put_packet("Time to stop".to_ascii())
# Client
while socket.wait() == OK:
var data = socket.get_packet().get_string_from_ascii()
if data == "Time to stop":
return
Returns whether this is listening.
Calling this method connects this UDP peer to the given host/port pair. UDP is in reality connectionless, so this option only means that incoming packets from different addresses are automatically discarded, and that outgoing packets are always sent to the connected address (future calls to are not allowed). This method does not send any data to the remote peer, to do that, use or as usual. See also .
Note: Connecting to the remote peer does not help to protect from malicious attacks like IP spoofing, etc. Think about using an encryption technique like SSL or DTLS if you feel like your application is transferring sensitive information.
Returns true if the UDP socket is open and has been connected to a remote address. See .
Returns the IP of the remote peer that sent the last packet(that was received with or ).
Returns the port of the remote peer that sent the last packet(that was received with or ).
Sets the destination address and port for sending packets and variables. A hostname will be resolved using DNS if needed.
Note: must be enabled before sending packets to a broadcast address (e.g. 255.255.255.255).
Enable or disable sending of broadcast packets (e.g. set_dest_address("255.255.255.255", 4343). This option is disabled by default.
Note: Some Android devices might require the CHANGE_WIFI_MULTICAST_STATE permission and this option to be enabled to receive broadcast packets too.
Joins the multicast group specified by multicast_address using the interface identified by interface_name.
You can join the same multicast group with multiple interfaces. Use to know which are available.
Note: Some Android devices might require the CHANGE_WIFI_MULTICAST_STATE permission for multicast to work.
Removes the interface identified by interface_name from the multicast group specified by multicast_address.
Panel is a that displays an opaque background. It's commonly used as a parent and container for other types of nodes.
Panel container type. This container fits controls inside of the delimited area of a stylebox. It's useful for giving controls an outline.
A resource referenced in an that is used to draw a background. The Panorama sky functions similar to skyboxes in other engines, except it uses an equirectangular sky map instead of a cube map.
Using an HDR panorama is strongly recommended for accurate, high-quality reflections. Godot supports the Radiance HDR (.hdr) and OpenEXR (.exr) image formats for this purpose.
You can use this tool to convert a cube map to an equirectangular sky map.
to be applied to the PanoramaSky.
A ParallaxBackground uses one or more child nodes to create a parallax effect. Each can move at a different speed using . This creates an illusion of depth in a 2D game. If not used with a , you must manually calculate the .
The ParallaxBackground's scroll value. Calculated automatically when using a , but can be used to manually manage scrolling when no camera is present.
The base position offset for all children.
The base motion scale for all children.
Top-left limits for scrolling to begin. If the camera is outside of this limit, the background will stop scrolling. Must be lower than to work.
Bottom-right limits for scrolling to end. If the camera is outside of this limit, the background will stop scrolling. Must be higher than to work.
If true, elements in child aren't affected by the zoom level of the camera.
A ParallaxLayer must be the child of a node. Each ParallaxLayer can be set to move at different speeds relative to the camera movement or the value.
This node's children will be affected by its scroll offset.
Note: Any changes to this node's position and scale made after it enters the scene will be ignored.
Multiplies the ParallaxLayer's motion. If an axis is set to 0, it will not scroll.
The ParallaxLayer's offset relative to the parent ParallaxBackground's .
The ParallaxLayer's mirroring. Useful for creating an infinite scrolling background. If an axis is set to 0, the will not be mirrored.
3D particle node used to create a variety of particle systems and effects. features an emitter that generates some number of particles at a given rate.
Use the process_material property to add a to configure particle appearance and behavior. Alternatively, you can add a which will be applied to all particles.
Note: only work when using the GLES3 renderer. If using the GLES2 renderer, use instead. You can convert to by selecting the node, clicking the Particles menu at the top of the 3D editor viewport then choosing Convert to CPUParticles.
Note: On macOS, rendering is much slower than due to transform feedback being implemented on the CPU instead of the GPU. Consider using instead when targeting macOS.
Note: After working on a Particles node, remember to update its by selecting it, clicking the Particles menu at the top of the 3D editor viewport then choose Generate Visibility AABB. Otherwise, particles may suddenly disappear depending on the camera position and angle.
Maximum number of draw passes supported.
Particles are drawn in the order emitted.
Particles are drawn in order of remaining lifetime.
Particles are drawn in order of depth.
If true, particles are being emitted.
The number of particles emitted in one emission cycle (corresponding to the ).
Note: Changing will reset the particle emission, therefore removing all particles that were already emitted before changing .
The amount of time each particle will exist (in seconds).
If true, only amount particles will be emitted.
Amount of time to preprocess the particles before animation starts. Lets you start the animation some time after particles have started emitting.
Speed scaling ratio. A value of 0 can be used to pause the particles.
Time ratio between each emission. If 0, particles are emitted continuously. If 1, all particles are emitted simultaneously.
Emission randomness ratio.
The particle system's frame rate is fixed to a value. For instance, changing the value to 2 will make the particles render at 2 frames per second. Note this does not slow down the simulation of the particle system itself.
If true, results in fractional delta calculation which has a smoother particles display effect.
The that determines the node's region which needs to be visible on screen for the particle system to be active.
Grow the box if particles suddenly appear/disappear when the node enters/exits the screen. The can be grown via code or with the Particles → Generate AABB editor tool.
Note: If the in use is configured to cast shadows, you may want to enlarge this AABB to ensure the shadow is updated when particles are off-screen.
If true, particles use the parent node's coordinate space. If false, they use global coordinates.
Particle draw order. Uses values.
for processing particles. Can be a or a .
The number of draw passes when rendering particles.
that is drawn for the first draw pass.
that is drawn for the second draw pass.
that is drawn for the third draw pass.
that is drawn for the fourth draw pass.
Sets the that is drawn at index pass.
Returns the that is drawn at index pass.
Restarts the particle emission, clearing existing particles.
Returns the axis-aligned bounding box that contains all the particles that are active in the current frame.
2D particle node used to create a variety of particle systems and effects. features an emitter that generates some number of particles at a given rate.
Use the process_material property to add a to configure particle appearance and behavior. Alternatively, you can add a which will be applied to all particles.
Note: only work when using the GLES3 renderer. If using the GLES2 renderer, use instead. You can convert to by selecting the node, clicking the Particles menu at the top of the 2D editor viewport then choosing Convert to CPUParticles2D.
Note: On macOS, rendering is much slower than due to transform feedback being implemented on the CPU instead of the GPU. Consider using instead when targeting macOS.
Note: After working on a Particles node, remember to update its by selecting it, clicking the Particles menu at the top of the 2D editor viewport then choose Generate Visibility Rect. Otherwise, particles may suddenly disappear depending on the camera position and angle.
Note: Unlike , currently ignore the texture region defined in s.
Particles are drawn in the order emitted.
Particles are drawn in order of remaining lifetime.
If true, particles are being emitted.
The number of particles emitted in one emission cycle (corresponding to the ).
Note: Changing will reset the particle emission, therefore removing all particles that were already emitted before changing .
The amount of time each particle will exist (in seconds).
If true, only one emission cycle occurs. If set true during a cycle, emission will stop at the cycle's end.
Particle system starts as if it had already run for this many seconds.
Particle system's running speed scaling ratio. A value of 0 can be used to pause the particles.
How rapidly particles in an emission cycle are emitted. If greater than 0, there will be a gap in emissions before the next cycle begins.
Emission lifetime randomness ratio.
The particle system's frame rate is fixed to a value. For instance, changing the value to 2 will make the particles render at 2 frames per second. Note this does not slow down the simulation of the particle system itself.
If true, results in fractional delta calculation which has a smoother particles display effect.
The that determines the node's region which needs to be visible on screen for the particle system to be active.
Grow the rect if particles suddenly appear/disappear when the node enters/exits the screen. The can be grown via code or with the Particles → Generate Visibility Rect editor tool.
If true, particles use the parent node's coordinate space. If false, they use global coordinates.
Particle draw order. Uses values.
for processing particles. Can be a or a .
Particle texture. If null, particles will be squares.
Normal map to be used for the property.
Note: Godot expects the normal map to use X+, Y-, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.
Returns a rectangle containing the positions of all existing particles.
Restarts all the existing particles.
ParticlesMaterial defines particle properties and behavior. It is used in the process_material of and emitter nodes.
Some of this material's properties are applied to each particle when emitted, while others can have a applied to vary values over the lifetime of the particle.
When a randomness ratio is applied to a property it is used to scale that property by a random amount. The random ratio is used to interpolate between 1.0 and a random number less than one, the result is multiplied by the property to obtain the randomized property. For example a random ratio of 0.4 would scale the original property between 0.4-1.0 of its original value.
Use with to set .
Use with to set .
Use with to set .
Represents the size of the enum.
All particles will be emitted from a single point.
Particles will be emitted in the volume of a sphere.
Particles will be emitted in the volume of a box.
Particles will be emitted at a position determined by sampling a random point on the . Particle color will be modulated by .
Particles will be emitted at a position determined by sampling a random point on the . Particle velocity and rotation will be set based on . Particle color will be modulated by .
Particles will be emitted in a ring or cylinder.
Represents the size of the enum.
Use with , , and to set initial velocity properties.
Use with , , and to set angular velocity properties.
Use with , , and to set orbital velocity properties.
Use with , , and to set linear acceleration properties.
Use with , , and to set radial acceleration properties.
Use with , , and to set tangential acceleration properties.
Use with , , and to set damping properties.
Use with , , and to set angle properties.
Use with , , and to set scale properties.
Use with , , and to set hue variation properties.
Use with , , and to set animation speed properties.
Use with , , and to set animation offset properties.
Represents the size of the enum.
Particle lifetime randomness ratio.
Emitter will emit amount divided by trail_divisor particles. The remaining particles will be used as trail(s).
Trail particles' size will vary along this .
Trail particles' color will vary along this .
Particles will be emitted inside this region. Use constants for values.
The sphere's radius if emission_shape is set to .
The box's extents if emission_shape is set to .
Particles will be emitted at positions determined by sampling this texture at a random position. Used with and . Can be created automatically from mesh or node by selecting "Create Emission Points from Mesh/Node" under the "Particles" tool in the toolbar.
Particle velocity and rotation will be set by sampling this texture at the same point as the . Used only in . Can be created automatically from mesh or node by selecting "Create Emission Points from Mesh/Node" under the "Particles" tool in the toolbar.
Particle color will be modulated by color determined by sampling this texture at the same point as the .
The number of emission points if emission_shape is set to or .
The radius of the ring when using the emitter .
The inner radius of the ring when using the emitter .
The height of the ring when using the emitter .
The axis of the ring when using the emitter .
Align Y axis of particle with the direction of its velocity.
If true, particles rotate around Y axis by .
If true, particles will not move on the z axis.
Unit vector specifying the particles' emission direction.
Each particle's initial direction range from +spread to -spread degrees.
Amount of along the Y axis.
Gravity applied to every particle.
Initial velocity magnitude for each particle. Direction comes from and the node's orientation.
Initial velocity randomness ratio.
Initial angular velocity applied to each particle in degrees per second. Sets the speed of rotation of the particle.
Note: Only applied when or are true or the being used to draw the particle is using .
Angular velocity randomness ratio.
Each particle's angular velocity will vary along this .
Orbital velocity applied to each particle. Makes the particles circle around origin. Specified in number of full rotations around origin per second.
Note: Only available when is true.
Orbital velocity randomness ratio.
Each particle's orbital velocity will vary along this .
Linear acceleration applied to each particle in the direction of motion.
Linear acceleration randomness ratio.
Each particle's linear acceleration will vary along this .
Radial acceleration applied to each particle. Makes particle accelerate away from origin.
Radial acceleration randomness ratio.
Each particle's radial acceleration will vary along this .
Tangential acceleration applied to each particle. Tangential acceleration is perpendicular to the particle's velocity giving the particles a swirling motion.
Tangential acceleration randomness ratio.
Each particle's tangential acceleration will vary along this .
The rate at which particles lose velocity.
Damping randomness ratio.
Damping will vary along this .
Initial rotation applied to each particle, in degrees.
Note: Only applied when or are true or the being used to draw the particle is using .
Rotation randomness ratio.
Each particle's rotation will be animated along this .
Initial scale applied to each particle.
Scale randomness ratio.
Each particle's scale will vary along this .
Each particle's initial color. If the 's texture is defined, it will be multiplied by this color. To have particle display color in a make sure to set to true.
Each particle's color will vary along this over its lifetime (multiplied with ).
Each particle's initial color will vary along this (multiplied with ).
Initial hue variation applied to each particle.
Hue variation randomness ratio.
Each particle's hue will vary along this .
Particle animation speed.
Animation speed randomness ratio.
Each particle's animation speed will vary along this .
Particle animation offset.
Animation offset randomness ratio.
Each particle's animation offset will vary along this .
Sets the specified .
Returns the value of the specified parameter.
Sets the randomness ratio for the specified .
Returns the randomness ratio associated with the specified parameter.
Sets the for the specified .
Returns the used by the specified parameter.
If true, enables the specified flag. See for options.
Returns true if the specified flag is enabled.
Can have child nodes moving along the . See for more information on the usage.
Note that the path is considered as relative to the moved nodes (children of ). As such, the curve should usually start with a zero vector (0, 0, 0).
A describing the path.
Can have child nodes moving along the . See for more information on usage.
Note: The path is considered as relative to the moved nodes (children of ). As such, the curve should usually start with a zero vector ((0, 0)).
A describing the path.
This node takes its parent , and returns the coordinates of a point within it, given a distance from the first vertex.
It is useful for making other nodes follow a path, without coding the movement pattern. For that, the nodes must be children of this node. The descendant nodes will then move accordingly when setting an offset in this node.
Forbids the PathFollow to rotate.
Allows the PathFollow to rotate in the Y axis only.
Allows the PathFollow to rotate in both the X, and Y axes.
Allows the PathFollow to rotate in any axis.
Uses the up vector information in a to enforce orientation. This rotation mode requires the 's property to be set to true.
The distance from the first vertex, measured in 3D units along the path. This sets this node's position to a point within the path.
The distance from the first vertex, considering 0.0 as the first vertex and 1.0 as the last. This is just another way of expressing the offset within the path, as the offset supplied is multiplied internally by the path's length.
The node's offset along the curve.
The node's offset perpendicular to the curve.
Allows or forbids rotation on one or more axes, depending on the constants being used.
If true, the position between two cached points is interpolated cubically, and linearly otherwise.
The points along the of the are precomputed before use, for faster calculations. The point at the requested offset is then calculated interpolating between two adjacent cached points. This may present a problem if the curve makes sharp turns, as the cached points may not follow the curve closely enough.
There are two answers to this problem: either increase the number of cached points and increase memory consumption, or make a cubic interpolation between two points at the cost of (slightly) slower calculations.
If true, any offset outside the path's length will wrap around, instead of stopping at the ends. Use it for cyclic paths.
This node takes its parent , and returns the coordinates of a point within it, given a distance from the first vertex.
It is useful for making other nodes follow a path, without coding the movement pattern. For that, the nodes must be children of this node. The descendant nodes will then move accordingly when setting an offset in this node.
The distance along the path in pixels.
The distance along the path as a number in the range 0.0 (for the first vertex) to 1.0 (for the last). This is just another way of expressing the offset within the path, as the offset supplied is multiplied internally by the path's length.
The node's offset along the curve.
The node's offset perpendicular to the curve.
If true, this node rotates to follow the path, making its descendants rotate.
If true, the position between two cached points is interpolated cubically, and linearly otherwise.
The points along the of the are precomputed before use, for faster calculations. The point at the requested offset is then calculated interpolating between two adjacent cached points. This may present a problem if the curve makes sharp turns, as the cached points may not follow the curve closely enough.
There are two answers to this problem: either increase the number of cached points and increase memory consumption, or make a cubic interpolation between two points at the cost of (slightly) slower calculations.
If true, any offset outside the path's length will wrap around, instead of stopping at the ends. Use it for cyclic paths.
How far to look ahead of the curve to calculate the tangent if the node is rotating. E.g. shorter lookaheads will lead to faster rotations.
This class provides access to a number of different monitors related to performance, such as memory usage, draw calls, and FPS. These are the same as the values displayed in the Monitor tab in the editor's Debugger panel. By using the method of this class, you can access this data from your code.
Note: A few of these monitors are only available in debug mode and will always return 0 when used in a release build.
Note: Many of these monitors are not updated in real-time, so there may be a short delay between changes.
Number of frames per second.
Time it took to complete one frame, in seconds.
Time it took to complete one physics frame, in seconds.
Static memory currently used, in bytes. Not available in release builds.
Dynamic memory currently used, in bytes. Not available in release builds.
Available static memory. Not available in release builds.
Available dynamic memory. Not available in release builds.
Largest amount of memory the message queue buffer has used, in bytes. The message queue is used for deferred functions calls and notifications.
Number of objects currently instanced (including nodes).
Number of resources currently used.
Number of nodes currently instanced in the scene tree. This also includes the root node.
Number of orphan nodes, i.e. nodes which are not parented to a node of the scene tree.
3D objects drawn per frame.
Vertices drawn per frame. 3D only.
Material changes per frame. 3D only.
Shader changes per frame. 3D only.
Render surface changes per frame. 3D only.
Draw calls per frame. 3D only.
Items or joined items drawn per frame.
Draw calls per frame.
The amount of video memory used, i.e. texture and vertex memory combined.
The amount of texture memory used.
The amount of vertex memory used.
Unimplemented in the GLES2 and GLES3 rendering backends, always returns 0.
Number of active nodes in the game.
Number of collision pairs in the 2D physics engine.
Number of islands in the 2D physics engine.
Number of active and nodes in the game.
Number of collision pairs in the 3D physics engine.
Number of islands in the 3D physics engine.
Output latency of the .
Represents the size of the enum.
Returns the value of one of the available monitors. You should provide one of the constants as the argument, like this:
print(Performance.get_monitor(Performance.TIME_FPS)) # Prints the FPS to the console
Provides direct access to a physics body in the , allowing safe changes to physics properties. This object is passed via the direct state callback of rigid/character bodies, and is intended for changing the direct state of that body. See .
The timestep (delta) used for the simulation.
The inverse of the mass of the body.
The inverse of the inertia of the body.
The rate at which the body stops rotating, if there are not any other forces moving it.
The rate at which the body stops moving, if there are not any other forces moving it.
The total gravity vector being currently applied to this body.
The body's rotational velocity in radians per second.
The body's linear velocity in pixels per second.
If true, this body is currently sleeping (not active).
The body's transformation matrix.
Returns the body's velocity at the given relative position, including both translation and rotation.
Adds a constant directional force without affecting rotation.
Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
Adds a constant rotational force.
Applies a directional impulse without affecting rotation.
Applies a rotational impulse to the body.
Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise). The offset uses the rotation of the global coordinate system, but is centered at the object's origin.
Returns the number of contacts this body has with other bodies.
Note: By default, this returns 0 unless bodies are configured to monitor contacts. See .
Returns the local position of the contact point.
Returns the local normal at the contact point.
Returns the local shape index of the collision.
Returns the collider's .
Returns the contact position in the collider.
Returns the collider's object id.
Returns the collider object. This depends on how it was created (will return a scene node if such was used to create it).
Returns the collider's shape index.
Returns the collided shape's metadata. This metadata is different from , and is set with .
Returns the linear velocity vector at the collider's contact point.
Calls the built-in force integration code.
Returns the current state of the space, useful for queries.
Direct access object to a space in the . It's used mainly to do queries against objects and areas residing in a given space.
Checks whether a point is inside any solid shape. The shapes the point is inside of are returned in an array containing dictionaries with the following fields:
collider: The colliding object.
collider_id: The colliding object's ID.
metadata: The intersecting shape's metadata. This metadata is different from , and is set with .
rid: The intersecting object's .
shape: The shape index of the colliding shape.
The number of intersections can be limited with the max_results parameter, to reduce the processing time.
Additionally, the method can take an exclude array of objects or s that are to be excluded from collisions, a collision_mask bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with s or s, respectively.
Note: s and s in Segments build mode are not solid shapes. Therefore, they will not be detected.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Checks whether a point is inside any solid shape, in a specific canvas layer given by canvas_instance_id. The shapes the point is inside of are returned in an array containing dictionaries with the following fields:
collider: The colliding object.
collider_id: The colliding object's ID.
metadata: The intersecting shape's metadata. This metadata is different from , and is set with .
rid: The intersecting object's .
shape: The shape index of the colliding shape.
The number of intersections can be limited with the max_results parameter, to reduce the processing time.
Additionally, the method can take an exclude array of objects or s that are to be excluded from collisions, a collision_mask bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with s or s, respectively.
Note: s and s in Segments build mode are not solid shapes. Therefore, they will not be detected.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Intersects a ray in a given space. The returned object is a dictionary with the following fields:
collider: The colliding object.
collider_id: The colliding object's ID.
metadata: The intersecting shape's metadata. This metadata is different from , and is set with .
normal: The object's surface normal at the intersection point.
position: The intersection point.
rid: The intersecting object's .
shape: The shape index of the colliding shape.
If the ray did not intersect anything, then an empty dictionary is returned instead.
Additionally, the method can take an exclude array of objects or s that are to be excluded from collisions, a collision_mask bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with s or s, respectively.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Checks the intersections of a shape, given through a object, against the space. The intersected shapes are returned in an array containing dictionaries with the following fields:
collider: The colliding object.
collider_id: The colliding object's ID.
metadata: The intersecting shape's metadata. This metadata is different from , and is set with .
rid: The intersecting object's .
shape: The shape index of the colliding shape.
The number of intersections can be limited with the max_results parameter, to reduce the processing time.
Checks how far a can move without colliding. All the parameters for the query, including the shape and the motion, are supplied through a object.
Returns an array with the safe and unsafe proportions (between 0 and 1) of the motion. The safe proportion is the maximum fraction of the motion that can be made without a collision. The unsafe proportion is the minimum fraction of the distance that must be moved for a collision. If no collision is detected a result of [1.0, 1.0] will be returned.
Note: Any s that the shape is already colliding with e.g. inside of, will be ignored. Use to determine the s that the shape is already colliding with.
Checks the intersections of a shape, given through a object, against the space. The resulting array contains a list of points where the shape intersects another. Like with , the number of returned results can be limited to save processing time.
Checks the intersections of a shape, given through a object, against the space. If it collides with more than one shape, the nearest one is selected. If the shape did not intersect anything, then an empty dictionary is returned instead.
Note: This method does not take into account the motion property of the object. The returned object is a dictionary containing the following fields:
collider_id: The colliding object's ID.
linear_velocity: The colliding object's velocity . If the object is an , the result is (0, 0).
metadata: The intersecting shape's metadata. This metadata is different from , and is set with .
normal: The object's surface normal at the intersection point.
point: The intersection point.
rid: The intersecting object's .
shape: The shape index of the colliding shape.
Physics2DServer is the server responsible for all 2D physics. It can create many kinds of physics objects, but does not insert them on the node tree.
Constant to get the number of objects that are not sleeping.
Constant to get the number of possible collisions.
Constant to get the number of space regions where a collision could occur.
The value of the first parameter and area callback function receives, when an object enters one of its shapes.
The value of the first parameter and area callback function receives, when an object exits one of its shapes.
Sets the resting length of the spring joint. The joint will always try to go to back this length when pulled apart.
Sets the stiffness of the spring joint. The joint applies a force equal to the stiffness times the distance from its resting length.
Sets the damping ratio of the spring joint. A value of 0 indicates an undamped spring, while 1 causes the system to reach equilibrium as fast as possible (critical damping).
Constant for static bodies.
Constant for kinematic bodies.
Constant for rigid bodies.
Constant for rigid bodies in character mode. In this mode, a body can not rotate, and only its linear velocity is affected by physics.
This is the constant for creating line shapes. A line shape is an infinite line with an origin point, and a normal. Thus, it can be used for front/behind checks.
This is the constant for creating segment shapes. A segment shape is a line from a point A to a point B. It can be checked for intersections.
This is the constant for creating circle shapes. A circle shape only has a radius. It can be used for intersections and inside/outside checks.
This is the constant for creating rectangle shapes. A rectangle shape is defined by a width and a height. It can be used for intersections and inside/outside checks.
This is the constant for creating capsule shapes. A capsule shape is defined by a radius and a length. It can be used for intersections and inside/outside checks.
This is the constant for creating convex polygon shapes. A polygon is defined by a list of points. It can be used for intersections and inside/outside checks. Unlike the property, polygons modified with do not verify that the points supplied form is a convex polygon.
This is the constant for creating concave polygon shapes. A polygon is defined by a list of points. It can be used for intersections checks, but not for inside/outside checks.
This constant is used internally by the engine. Any attempt to create this kind of shape results in an error.
Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated.
Constant to set/get the maximum distance a shape can be from another before they are considered separated.
Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision.
Constant to set/get the threshold linear velocity of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after the time given.
Constant to set/get the threshold angular velocity of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after the time given.
Constant to set/get the maximum time of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after this time.
Constant to set/get the default solver bias for all physics constraints. A solver bias is a factor controlling how much two objects "rebound", after violating a constraint, to avoid leaving them in that state because of numerical imprecision.
Constant to create pin joints.
Constant to create groove joints.
Constant to create damped spring joints.
Disables continuous collision detection. This is the fastest way to detect body collisions, but can miss small, fast-moving objects.
Enables continuous collision detection by raycasting. It is faster than shapecasting, but less precise.
Enables continuous collision detection by shapecasting. It is the slowest CCD method, and the most precise.
Constant to set/get the current transform matrix of the body.
Constant to set/get the current linear velocity of the body.
Constant to set/get the current angular velocity of the body.
Constant to sleep/wake up a body, or to get whether it is sleeping.
Constant to set/get whether the body can sleep.
Constant to set/get a body's bounce factor.
Constant to set/get a body's friction.
Constant to set/get a body's mass.
Constant to set/get a body's inertia.
Constant to set/get a body's gravity multiplier.
Constant to set/get a body's linear dampening factor.
Constant to set/get a body's angular dampening factor.
Represents the size of the enum.
This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them.
This area adds its gravity/damp values to whatever has been calculated so far. This way, many overlapping areas can combine their physics to make interesting effects.
This area adds its gravity/damp values to whatever has been calculated so far. Then stops taking into account the rest of the areas, even the default one.
This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas.
This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.
Constant to set/get gravity strength in an area.
Constant to set/get gravity vector/center in an area.
Constant to set/get whether the gravity vector of an area is a direction, or a center point.
Constant to set/get the falloff factor for point gravity of an area. The greater this value is, the faster the strength of gravity decreases with the square of distance.
This constant was used to set/get the falloff factor for point gravity. It has been superseded by .
Constant to set/get the linear dampening factor of an area.
Constant to set/get the angular dampening factor of an area.
Constant to set/get the priority (order of processing) of an area.
Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created .
Returns a shape's type (see ).
Returns the shape data.
Creates a space. A space is a collection of parameters for the physics engine that can be assigned to an area or a body. It can be assigned to an area with , or to a body with .
Marks a space as active. It will not have an effect, unless it is assigned to an area or body.
Returns whether the space is active.
Sets the value for a space parameter. See for a list of available parameters.
Returns the value of a space parameter.
Returns the state of a space, a . This object can be used to make collision/intersection queries.
Creates an . After creating an with this method, assign it to a space using to use the created in the physics world.
Assigns a space to the area.
Returns the space assigned to the area.
Sets the space override mode for the area. See for a list of available modes.
Returns the space override mode for the area.
Adds a shape to the area, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index.
If the parameter is null, then the default value is Transform2D.Identity
Substitutes a given area shape by another. The old shape is selected by its index, the new one by its .
Sets the transform matrix for an area shape.
Disables a given shape in an area.
Returns the number of shapes assigned to an area.
Returns the of the nth shape of an area.
Returns the transform matrix of a shape within an area.
Removes a shape from an area. It does not delete the shape, so it can be reassigned later.
Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later.
Assigns the area to one or many physics layers.
Sets which physics layers the area will monitor.
Sets the value for an area parameter. See for a list of available parameters.
Sets the transform matrix for an area.
Returns an area parameter value. See for a list of available parameters.
Returns the transform matrix for an area.
Assigns the area to a descendant of , so it can exist in the node tree.
Gets the instance ID of the object the area is assigned to.
Sets the function to call when any body/area enters or exits the area. This callback will be called for any object interacting with the area, and takes five parameters:
1: or , depending on whether the object entered or exited the area.
2: of the object that entered/exited the area.
3: Instance ID of the object that entered/exited the area.
4: The shape index of the object that entered/exited the area.
5: The shape index of the area where the object entered/exited.
Creates a physics body.
Assigns a space to the body (see ).
Returns the of the space assigned to a body.
Sets the body mode using one of the constants.
Returns the body mode.
Adds a shape to the body, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index.
If the parameter is null, then the default value is Transform2D.Identity
Substitutes a given body shape by another. The old shape is selected by its index, the new one by its .
Sets the transform matrix for a body shape.
Sets metadata of a shape within a body. This metadata is different from , and can be retrieved on shape queries.
Returns the number of shapes assigned to a body.
Returns the of the nth shape of a body.
Returns the transform matrix of a body shape.
Returns the metadata of a shape of a body.
Removes a shape from a body. The shape is not deleted, so it can be reused afterwards.
Removes all shapes from a body.
Disables shape in body if disable is true.
Enables one way collision on body if enable is true.
Assigns the area to a descendant of , so it can exist in the node tree.
Gets the instance ID of the object the area is assigned to.
Sets the continuous collision detection mode using one of the constants.
Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided.
Returns the continuous collision detection mode.
Sets the physics layer or layers a body belongs to.
Returns the physics layer or layers a body belongs to.
Sets the physics layer or layers a body can collide with.
Returns the physics layer or layers a body can collide with.
Sets a body parameter. See for a list of available parameters.
Returns the value of a body parameter. See for a list of available parameters.
Sets a body state using one of the constants.
Note that the method doesn't take effect immediately. The state will change on the next physics frame.
Returns a body state.
Adds a positioned impulse to the applied force and torque. Both the force and the offset from the body origin are in global coordinates.
Adds a positioned force to the applied force and torque. As with , both the force and the offset from the body origin are in global coordinates. A force differs from an impulse in that, while the two are forces, the impulse clears itself after being applied.
Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.
Adds a body to the list of bodies exempt from collisions.
Removes a body from the list of bodies exempt from collisions.
Sets the maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.
Returns the maximum contacts that can be reported. See .
Sets whether a body uses a callback function to calculate its own physics (see ).
Returns whether a body uses a callback function to calculate its own physics (see ).
Sets the function used to calculate physics for an object, if that object allows it (see ).
Returns true if a collision would result from moving in the given direction from a given point in space. Margin increases the size of the shapes involved in the collision detection. can be passed to return additional information in.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Returns the of the body. Returns null if the body is destroyed or removed from the physics space.
Sets a joint parameter. See for a list of available parameters.
Returns the value of a joint parameter.
Creates a pin joint between two bodies. If not specified, the second body is assumed to be the joint itself.
Creates a groove joint between two bodies. If not specified, the bodies are assumed to be the joint itself.
Creates a damped spring joint between two bodies. If not specified, the second body is assumed to be the joint itself.
Sets a damped spring joint parameter. See for a list of available parameters.
Returns the value of a damped spring joint parameter.
Returns a joint's type (see ).
Destroys any of the objects created by Physics2DServer. If the passed is not one of the objects that can be created by Physics2DServer, an error will be sent to the console.
Activates or deactivates the 2D physics engine.
Sets the amount of iterations for calculating velocities of colliding bodies. The greater the amount of iterations, the more accurate the collisions will be. However, a greater amount of iterations requires more CPU power, which can decrease performance. The default value is 8.
Returns information about the current state of the 2D physics engine. See for a list of available states.
This class contains the shape and other parameters for 2D intersection/collision queries.
The physics layer(s) the query will take into account (as a bitmask). See Collision layers and masks in the documentation for more information.
The list of objects or object s that will be excluded from collisions.
The collision margin for the shape.
The motion of the shape being queried for.
The queried shape's . See also .
The queried shape's transform matrix.
If true, the query will take s into account.
If true, the query will take s into account.
Sets the that will be used for collision/intersection queries.
PhysicsBody is an abstract base class for implementing a physics body. All *Body types inherit from it.
Returns an array of nodes that were added as collision exceptions for this body.
Adds a body to the list of bodies that this body can't collide with.
Removes a body from the list of bodies that this body can't collide with.
PhysicsBody2D is an abstract base class for implementing a physics body. All *Body2D types inherit from it.
Both collision_layer and collision_mask. Returns collision_layer when accessed. Updates collision_layer and collision_mask when modified.
Returns an array of nodes that were added as collision exceptions for this body.
Adds a body to the list of bodies that this body can't collide with.
Removes a body from the list of bodies that this body can't collide with.
Provides direct access to a physics body in the , allowing safe changes to physics properties. This object is passed via the direct state callback of rigid/character bodies, and is intended for changing the direct state of that body. See .
The timestep (delta) used for the simulation.
The inverse of the mass of the body.
The rate at which the body stops rotating, if there are not any other forces moving it.
The rate at which the body stops moving, if there are not any other forces moving it.
The inverse of the inertia of the body.
The total gravity vector being currently applied to this body.
The body's rotational velocity in axis-angle format. The magnitude of the vector is the rotation rate in radians per second.
The body's linear velocity in units per second.
If true, this body is currently sleeping (not active).
The body's transformation matrix.
Returns the body's velocity at the given relative position, including both translation and rotation.
Adds a constant directional force without affecting rotation.
This is equivalent to add_force(force, Vector3(0,0,0)).
Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
Adds a constant rotational force without affecting position.
Applies a single directional impulse without affecting rotation.
This is equivalent to apply_impulse(Vector3(0, 0, 0), impulse).
Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts. The position uses the rotation of the global coordinate system, but is centered at the object's origin.
Apply a torque impulse (which will be affected by the body mass and shape). This will rotate the body around the vector j passed as parameter.
Returns the number of contacts this body has with other bodies.
Note: By default, this returns 0 unless bodies are configured to monitor contacts. See .
Returns the local position of the contact point.
Returns the local normal at the contact point.
Impulse created by the contact. Only implemented for Bullet physics.
Returns the local shape index of the collision.
Returns the collider's .
Returns the contact position in the collider.
Returns the collider's object id.
Returns the collider object.
Returns the collider's shape index.
Returns the linear velocity vector at the collider's contact point.
Calls the built-in force integration code.
Returns the current state of the space, useful for queries.
Direct access object to a space in the . It's used mainly to do queries against objects and areas residing in a given space.
Checks whether a point is inside any solid shape. The shapes the point is inside of are returned in an array containing dictionaries with the following fields:
collider: The colliding object.
collider_id: The colliding object's ID.
rid: The intersecting object's .
shape: The shape index of the colliding shape.
The number of intersections can be limited with the max_results parameter, to reduce the processing time.
Additionally, the method can take an exclude array of objects or s that are to be excluded from collisions, a collision_mask bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with s or s, respectively.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Intersects a ray in a given space. The returned object is a dictionary with the following fields:
collider: The colliding object.
collider_id: The colliding object's ID.
normal: The object's surface normal at the intersection point.
position: The intersection point.
rid: The intersecting object's .
shape: The shape index of the colliding shape.
If the ray did not intersect anything, then an empty dictionary is returned instead.
Additionally, the method can take an exclude array of objects or s that are to be excluded from collisions, a collision_mask bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with s or s, respectively.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Checks the intersections of a shape, given through a object, against the space. The intersected shapes are returned in an array containing dictionaries with the following fields:
collider: The colliding object.
collider_id: The colliding object's ID.
rid: The intersecting object's .
shape: The shape index of the colliding shape.
The number of intersections can be limited with the max_results parameter, to reduce the processing time.
Checks how far a can move without colliding. All the parameters for the query, including the shape, are supplied through a object.
Returns an array with the safe and unsafe proportions (between 0 and 1) of the motion. The safe proportion is the maximum fraction of the motion that can be made without a collision. The unsafe proportion is the minimum fraction of the distance that must be moved for a collision. If no collision is detected a result of [1.0, 1.0] will be returned.
Note: Any s that the shape is already colliding with e.g. inside of, will be ignored. Use to determine the s that the shape is already colliding with.
Checks the intersections of a shape, given through a object, against the space. The resulting array contains a list of points where the shape intersects another. Like with , the number of returned results can be limited to save processing time.
Checks the intersections of a shape, given through a object, against the space. If it collides with more than one shape, the nearest one is selected. The returned object is a dictionary containing the following fields:
collider_id: The colliding object's ID.
linear_velocity: The colliding object's velocity . If the object is an , the result is (0, 0, 0).
normal: The object's surface normal at the intersection point.
point: The intersection point.
rid: The intersecting object's .
shape: The shape index of the colliding shape.
If the shape did not intersect anything, then an empty dictionary is returned instead.
Provides a means of modifying the collision properties of a .
The body's friction. Values range from 0 (frictionless) to 1 (maximum friction).
If true, the physics engine will use the friction of the object marked as "rough" when two objects collide. If false, the physics engine will use the lowest friction of all colliding objects instead. If true for both colliding objects, the physics engine will use the highest friction.
The body's bounciness. Values range from 0 (no bounce) to 1 (full bounciness).
If true, subtracts the bounciness from the colliding object's bounciness instead of adding it.
PhysicsServer is the server responsible for all 3D physics. It can create many kinds of physics objects, but does not insert them on the node tree.
Constant to get the number of objects that are not sleeping.
Constant to get the number of possible collisions.
Constant to get the number of space regions where a collision could occur.
The value of the first parameter and area callback function receives, when an object enters one of its shapes.
The value of the first parameter and area callback function receives, when an object exits one of its shapes.
Constant for static bodies.
Constant for kinematic bodies.
Constant for rigid bodies.
Constant for rigid bodies in character mode. In this mode, a body can not rotate, and only its linear velocity is affected by physics.
The is a .
The is a .
The is a .
The is a .
The is a .
The is a .
The is a .
The is a .
The is a .
This constant is used internally by the engine. Any attempt to create this kind of shape results in an error.
The strength with which the pinned objects try to stay in positional relation to each other.
The higher, the stronger.
The strength with which the pinned objects try to stay in velocity relation to each other.
The higher, the stronger.
If above 0, this value is the maximum value for an impulse that this Joint puts on its ends.
Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated.
Constant to set/get the maximum distance a shape can be from another before they are considered separated.
Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision.
Constant to set/get the threshold linear velocity of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after the time given.
Constant to set/get the threshold angular velocity of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after the time given.
Constant to set/get the maximum time of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after this time.
Constant to set/get the default solver bias for all physics constraints. A solver bias is a factor controlling how much two objects "rebound", after violating a constraint, to avoid leaving them in that state because of numerical imprecision.
Swing is rotation from side to side, around the axis perpendicular to the twist axis.
The swing span defines, how much rotation will not get corrected along the swing axis.
Could be defined as looseness in the .
If below 0.05, this behavior is locked.
Twist is the rotation around the twist axis, this value defined how far the joint can twist.
Twist is locked if below 0.05.
The speed with which the swing or twist will take place.
The higher, the faster.
The ease with which the Joint twists, if it's too low, it takes more force to twist the joint.
Defines, how fast the swing- and twist-speed-difference on both sides gets synced.
The is a .
The is a .
The is a .
The is a .
The is a .
Constant to set/get the current transform matrix of the body.
Constant to set/get the current linear velocity of the body.
Constant to set/get the current angular velocity of the body.
Constant to sleep/wake up a body, or to get whether it is sleeping.
Constant to set/get whether the body can sleep.
Constant to set/get a body's bounce factor.
Constant to set/get a body's friction.
Constant to set/get a body's mass.
Constant to set/get a body's gravity multiplier.
Constant to set/get a body's linear dampening factor.
Constant to set/get a body's angular dampening factor.
Represents the size of the enum.
The minimum difference between the pivot points' axes.
The maximum difference between the pivot points' axes.
A factor that gets applied to the movement across the axes. The lower, the slower the movement.
The amount of restitution on the axes movement. The lower, the more velocity-energy gets lost.
The amount of damping that happens at the linear motion across the axes.
The velocity that the joint's linear motor will attempt to reach.
The maximum force that the linear motor can apply while trying to reach the target velocity.
The minimum rotation in negative direction to break loose and rotate around the axes.
The minimum rotation in positive direction to break loose and rotate around the axes.
A factor that gets multiplied onto all rotations across the axes.
The amount of rotational damping across the axes. The lower, the more dampening occurs.
The amount of rotational restitution across the axes. The lower, the more restitution occurs.
The maximum amount of force that can occur, when rotating around the axes.
When correcting the crossing of limits in rotation across the axes, this error tolerance factor defines how much the correction gets slowed down. The lower, the slower.
Target speed for the motor at the axes.
Maximum acceleration for the motor at the axes.
The maximum difference between the pivot points on their X axis before damping happens.
The minimum difference between the pivot points on their X axis before damping happens.
A factor applied to the movement across the slider axis once the limits get surpassed. The lower, the slower the movement.
The amount of restitution once the limits are surpassed. The lower, the more velocityenergy gets lost.
The amount of damping once the slider limits are surpassed.
A factor applied to the movement across the slider axis as long as the slider is in the limits. The lower, the slower the movement.
The amount of restitution inside the slider limits.
The amount of damping inside the slider limits.
A factor applied to the movement across axes orthogonal to the slider.
The amount of restitution when movement is across axes orthogonal to the slider.
The amount of damping when movement is across axes orthogonal to the slider.
The upper limit of rotation in the slider.
The lower limit of rotation in the slider.
A factor applied to the all rotation once the limit is surpassed.
The amount of restitution of the rotation when the limit is surpassed.
The amount of damping of the rotation when the limit is surpassed.
A factor that gets applied to the all rotation in the limits.
The amount of restitution of the rotation in the limits.
The amount of damping of the rotation in the limits.
A factor that gets applied to the all rotation across axes orthogonal to the slider.
The amount of restitution of the rotation across axes orthogonal to the slider.
The amount of damping of the rotation across axes orthogonal to the slider.
Represents the size of the enum.
The speed with which the two bodies get pulled together when they move in different directions.
The maximum rotation across the Hinge.
The minimum rotation across the Hinge.
The speed with which the rotation across the axis perpendicular to the hinge gets corrected.
The lower this value, the more the rotation gets slowed down.
Target speed for the motor.
Maximum acceleration for the motor.
If set, linear motion is possible within the given limits.
If set, rotational motion is possible.
If set, there is a rotational motor across these axes.
If set, there is a linear motor on this axis that targets a specific velocity.
If true, the Hinge has a maximum and a minimum rotation.
If true, a motor turns the Hinge.
This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them.
This area adds its gravity/damp values to whatever has been calculated so far. This way, many overlapping areas can combine their physics to make interesting effects.
This area adds its gravity/damp values to whatever has been calculated so far. Then stops taking into account the rest of the areas, even the default one.
This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas.
This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.
Constant to set/get gravity strength in an area.
Constant to set/get gravity vector/center in an area.
Constant to set/get whether the gravity vector of an area is a direction, or a center point.
Constant to set/get the falloff factor for point gravity of an area. The greater this value is, the faster the strength of gravity decreases with the square of distance.
This constant was used to set/get the falloff factor for point gravity. It has been superseded by .
Constant to set/get the linear dampening factor of an area.
Constant to set/get the angular dampening factor of an area.
Constant to set/get the priority (order of processing) of an area.
Creates a shape of a type from . Does not assign it to a body or an area. To do so, you must use or .
Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created .
Returns the type of shape (see constants).
Returns the shape data.
Creates a space. A space is a collection of parameters for the physics engine that can be assigned to an area or a body. It can be assigned to an area with , or to a body with .
Marks a space as active. It will not have an effect, unless it is assigned to an area or body.
Returns whether the space is active.
Sets the value for a space parameter. A list of available parameters is on the constants.
Returns the value of a space parameter.
Returns the state of a space, a . This object can be used to make collision/intersection queries.
Creates an .
Assigns a space to the area.
Returns the space assigned to the area.
Sets the space override mode for the area. The modes are described in the constants.
Returns the space override mode for the area.
Adds a shape to the area, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index.
If the parameter is null, then the default value is Transform.Identity
Substitutes a given area shape by another. The old shape is selected by its index, the new one by its .
Sets the transform matrix for an area shape.
Returns the number of shapes assigned to an area.
Returns the of the nth shape of an area.
Returns the transform matrix of a shape within an area.
Removes a shape from an area. It does not delete the shape, so it can be reassigned later.
Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later.
Assigns the area to one or many physics layers.
Sets which physics layers the area will monitor.
Sets the value for an area parameter. A list of available parameters is on the constants.
Sets the transform matrix for an area.
Returns an area parameter value. A list of available parameters is on the constants.
Returns the transform matrix for an area.
Assigns the area to a descendant of , so it can exist in the node tree.
Gets the instance ID of the object the area is assigned to.
Sets the function to call when any body/area enters or exits the area. This callback will be called for any object interacting with the area, and takes five parameters:
1: or , depending on whether the object entered or exited the area.
2: of the object that entered/exited the area.
3: Instance ID of the object that entered/exited the area.
4: The shape index of the object that entered/exited the area.
5: The shape index of the area where the object entered/exited.
Sets object pickable with rays.
If true, area collides with rays.
Creates a physics body. The first parameter can be any value from constants, for the type of body created. Additionally, the body can be created in sleeping state to save processing time.
Assigns a space to the body (see ).
Returns the of the space assigned to a body.
Sets the body mode, from one of the constants.
Returns the body mode.
Sets the physics layer or layers a body belongs to.
Returns the physics layer or layers a body belongs to.
Sets the physics layer or layers a body can collide with.
Returns the physics layer or layers a body can collide with.
Adds a shape to the body, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index.
If the parameter is null, then the default value is Transform.Identity
Substitutes a given body shape by another. The old shape is selected by its index, the new one by its .
Sets the transform matrix for a body shape.
Returns the number of shapes assigned to a body.
Returns the of the nth shape of a body.
Returns the transform matrix of a body shape.
Removes a shape from a body. The shape is not deleted, so it can be reused afterwards.
Removes all shapes from a body.
Assigns the area to a descendant of , so it can exist in the node tree.
Gets the instance ID of the object the area is assigned to.
If true, the continuous collision detection mode is enabled.
Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided.
If true, the continuous collision detection mode is enabled.
Sets a body parameter. A list of available parameters is on the constants.
Returns the value of a body parameter. A list of available parameters is on the constants.
Sets a body state (see constants).
Returns a body state.
Gives the body a push at a position in the direction of the impulse.
Gives the body a push to rotate it.
Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.
Adds a body to the list of bodies exempt from collisions.
Removes a body from the list of bodies exempt from collisions.
Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided.
Sets the maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.
Returns the maximum contacts that can be reported. See .
Sets whether a body uses a callback function to calculate its own physics (see ).
Returns whether a body uses a callback function to calculate its own physics (see ).
Sets the function used to calculate physics for an object, if that object allows it (see ).
Sets the body pickable with rays if enabled is set.
If true, the body can be detected by rays.
Returns true if a collision would result from moving in the given direction from a given point in space. can be passed to return additional information in.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Returns the of the body. Returns null if the body is destroyed or removed from the physics space.
Creates a .
Sets a pin_joint parameter (see constants).
Gets a pin_joint parameter (see constants).
Sets position of the joint in the local space of body a of the joint.
Returns position of the joint in the local space of body a of the joint.
Sets position of the joint in the local space of body b of the joint.
Returns position of the joint in the local space of body b of the joint.
Creates a .
Sets a hinge_joint parameter (see constants).
Gets a hinge_joint parameter (see ).
Sets a hinge_joint flag (see constants).
Gets a hinge_joint flag (see constants).
Creates a .
Gets a slider_joint parameter (see constants).
Gets a slider_joint parameter (see constants).
Creates a .
Sets a cone_twist_joint parameter (see constants).
Gets a cone_twist_joint parameter (see constants).
Returns the type of the Joint.
Sets the priority value of the Joint.
Gets the priority value of the Joint.
Creates a .
Sets a generic_6_DOF_joint parameter (see constants).
Gets a generic_6_DOF_joint parameter (see constants).
Sets a generic_6_DOF_joint flag (see constants).
Gets a generic_6_DOF_joint flag (see constants).
Destroys any of the objects created by PhysicsServer. If the passed is not one of the objects that can be created by PhysicsServer, an error will be sent to the console.
Activates or deactivates the 3D physics engine.
Sets the amount of iterations for calculating velocities of colliding bodies. The greater the amount of iterations, the more accurate the collisions will be. However, a greater amount of iterations requires more CPU power, which can decrease performance. The default value is 8.
Note: Only has an effect when using the GodotPhysics engine, not the default Bullet physics engine.
Returns information about the current state of the 3D physics engine. See for a list of available states. Only implemented for Godot Physics.
This class contains the shape and other parameters for 3D intersection/collision queries.
The physics layer(s) the query will take into account (as a bitmask). See Collision layers and masks in the documentation for more information.
The list of objects or object s that will be excluded from collisions.
The collision margin for the shape.
The queried shape's . See also .
The queried shape's transform matrix.
If true, the query will take s into account.
If true, the query will take s into account.
Sets the that will be used for collision/intersection queries.
Pin joint for 3D rigid bodies. It pins 2 bodies (rigid or static) together. See also .
The force with which the pinned objects stay in positional relation to each other. The higher, the stronger.
The force with which the pinned objects stay in velocity relation to each other. The higher, the stronger.
If above 0, this value is the maximum value for an impulse that this Joint produces.
The force with which the pinned objects stay in positional relation to each other. The higher, the stronger.
The force with which the pinned objects stay in velocity relation to each other. The higher, the stronger.
If above 0, this value is the maximum value for an impulse that this Joint produces.
Sets the value of the specified parameter.
Returns the value of the specified parameter.
Pin Joint for 2D rigid bodies. It pins two bodies (rigid or static) together.
The higher this value, the more the bond to the pinned partner can flex.
Class representing a planar . This flat mesh does not have a thickness. By default, this mesh is aligned on the X and Z axes; this default rotation isn't suited for use with billboarded materials. For billboarded materials, use instead.
Note: When using a large textured (e.g. as a floor), you may stumble upon UV jittering issues depending on the camera angle. To solve this, increase and until you no longer notice UV jittering.
Size of the generated plane.
Number of subdivision along the X axis.
Number of subdivision along the Z axis.
Offset from the origin of the generated plane. Useful for particles.
An infinite plane shape for 3D collisions. Note that the 's normal matters; anything "below" the plane will collide with it. If the is used in a , it will cause colliding objects placed "below" it to teleport "above" the plane.
The used by the for collision.
Returns a new instance of the script.
The PointMesh is made from a single point. Instead of relying on triangles, points are rendered as a single rectangle on the screen with a constant size. They are intended to be used with Particle systems, but can be used as a cheap way to render constant size billboarded sprites (for example in a point cloud).
PointMeshes, must be used with a material that has a point size. Point size can be accessed in a shader with POINT_SIZE, or in a by setting and the variable .
When using PointMeshes, properties that normally alter vertices will be ignored, including billboard mode, grow, and cull face.
A Polygon2D is defined by a set of points. Each point is connected to the next, with the final point being connected to the first, resulting in a closed polygon. Polygon2Ds can be filled with color (solid or gradient) or filled with a given texture.
Note: By default, Godot can only draw up to 4,096 polygon points at a time. To increase this limit, open the Project Settings and increase and .
The polygon's fill color. If texture is defined, it will be multiplied by this color. It will also be the default color for vertices not set in vertex_colors.
The offset applied to each vertex.
If true, attempts to perform antialiasing for polygon edges by drawing a thin OpenGL smooth line on the edges.
Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the Antialiased Line2D add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
The polygon's fill texture. Use uv to set texture coordinates.
Amount to offset the polygon's texture. If (0, 0) the texture's origin (its top-left corner) will be placed at the polygon's position.
Amount to multiply the uv coordinates when using a texture. Larger values make the texture smaller, and vice versa.
The texture's rotation in degrees.
The texture's rotation in radians.
If true, polygon will be inverted, containing the area outside the defined points and extending to the invert_border.
Added padding applied to the bounding box when using invert. Setting this value too small may result in a "Bad Polygon" error.
The polygon's list of vertices. The final point will be connected to the first.
Note: This returns a copy of the rather than a reference.
Texture coordinates for each vertex of the polygon. There should be one uv per polygon vertex. If there are fewer, undefined vertices will use (0, 0).
Color for each vertex. Colors are interpolated between vertices, resulting in smooth gradients. There should be one per polygon vertex. If there are fewer, undefined vertices will use color.
Adds a bone with the specified path and weights.
Returns the number of bones in this .
Returns the path to the node associated with the specified bone.
Returns the height values of the specified bone.
Removes the specified bone from this .
Removes all bones from this .
Sets the path to the node associated with the specified bone.
Sets the weight values for the specified bone.
Popup is a base used to show dialogs and popups. It's a subwindow and modal by default (see ) and has helpers for custom popup behavior. All popup methods ensure correct placement within the viewport.
Notification sent right after the popup is shown.
Notification sent right after the popup is hidden.
If true, the popup will not be hidden when a click event occurs outside of it, or when it receives the ui_cancel action event.
Note: Enabling this property doesn't affect the Close or Cancel buttons' behavior in dialogs that inherit from this class. As a workaround, you can use or and hide the buttons in question by setting their property to false.
Shrink popup to keep to the minimum size of content.
Popup (show the control in modal form) in the center of the screen relative to its current canvas transform, at the current size, or at a size determined by size.
If the parameter is null, then the default value is new Vector2(0, 0)
Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, scaled at a ratio of size of the screen.
Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, ensuring the size is never smaller than minsize.
If the parameter is null, then the default value is new Vector2(0, 0)
Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, clamping the size to size, then ensuring the popup is no larger than the viewport size multiplied by fallback_ratio.
If the parameter is null, then the default value is new Vector2(0, 0)
Popup (show the control in modal form).
If the parameter is null, then the default value is new Rect2(new Vector2(0, 0), new Vector2(0, 0))
PopupDialog is a base class for popup dialogs, along with .
is a that displays a list of options. They are popular in toolbars or context menus.
Incremental search: Like and , supports searching within the list while the control is focused. Press a key that matches the first letter of an item's name to select the first item starting with the given letter. After that point, there are two ways to perform incremental search: 1) Press the same key again before the timeout duration to select the next item starting with the same letter. 2) Press letter keys that match the rest of the word before the timeout duration to match to select the item in question directly. Both of these actions will be reset to the beginning of the list if the timeout duration has passed since the last keystroke was registered. You can adjust the timeout duration by changing .
If true, hides the when an item is selected.
If true, hides the when a checkbox or radio button is selected.
If true, hides the when a state item is selected.
Sets the delay time in seconds for the submenu item to popup on mouse hovering. If the popup menu is added as a child of another (acting as a submenu), it will inherit the delay time of the parent menu item.
If true, allows navigating with letter keys.
Adds a new item with text label.
An id can optionally be provided, as well as an accelerator (accel). If no id is provided, one will be created from the index. If no accel is provided then the default 0 will be assigned to it. See for more info on accelerators.
Adds a new item with text label and icon texture.
An id can optionally be provided, as well as an accelerator (accel). If no id is provided, one will be created from the index. If no accel is provided then the default 0 will be assigned to it. See for more info on accelerators.
Adds a new checkable item with text label.
An id can optionally be provided, as well as an accelerator (accel). If no id is provided, one will be created from the index. If no accel is provided then the default 0 will be assigned to it. See for more info on accelerators.
Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See for more info on how to control it.
Adds a new checkable item with text label and icon texture.
An id can optionally be provided, as well as an accelerator (accel). If no id is provided, one will be created from the index. If no accel is provided then the default 0 will be assigned to it. See for more info on accelerators.
Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See for more info on how to control it.
Adds a new radio check button with text label.
An id can optionally be provided, as well as an accelerator (accel). If no id is provided, one will be created from the index. If no accel is provided then the default 0 will be assigned to it. See for more info on accelerators.
Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See for more info on how to control it.
Same as , but uses a radio check button.
Adds a new multistate item with text label.
Contrarily to normal binary items, multistate items can have more than two states, as defined by max_states. Each press or activate of the item will increase the state by one. The default value is defined by default_state.
An id can optionally be provided, as well as an accelerator (accel). If no id is provided, one will be created from the index. If no accel is provided then the default 0 will be assigned to it. See for more info on accelerators.
Adds a .
An id can optionally be provided. If no id is provided, one will be created from the index.
Adds a new item and assigns the specified and icon texture to it. Sets the label of the checkbox to the 's name.
An id can optionally be provided. If no id is provided, one will be created from the index.
Adds a new checkable item and assigns the specified to it. Sets the label of the checkbox to the 's name.
An id can optionally be provided. If no id is provided, one will be created from the index.
Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See for more info on how to control it.
Adds a new checkable item and assigns the specified and icon texture to it. Sets the label of the checkbox to the 's name.
An id can optionally be provided. If no id is provided, one will be created from the index.
Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See for more info on how to control it.
Adds a new radio check button and assigns a to it. Sets the label of the checkbox to the 's name.
An id can optionally be provided. If no id is provided, one will be created from the index.
Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See for more info on how to control it.
Same as , but uses a radio check button.
Adds an item that will act as a submenu of the parent node when clicked. The submenu argument is the name of the child node that will be shown when the item is clicked.
An id can optionally be provided. If no id is provided, one will be created from the index.
Sets the text of the item at index idx.
Replaces the icon of the specified idx.
Sets the checkstate status of the item at index idx.
Sets the id of the item at index idx.
Sets the accelerator of the item at index idx. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
Sets the metadata of an item, which may be of any type. You can later get it with , which provides a simple way of assigning context data to items.
Enables/disables the item at index idx. When it is disabled, it can't be selected and its action can't be invoked.
Sets the submenu of the item at index idx. The submenu is the name of a child node that would be shown when the item is clicked.
Mark the item at index idx as a separator, which means that it would be displayed as a line. If false, sets the type of the item to plain text.
Sets whether the item at index idx has a checkbox. If false, sets the type of the item to plain text.
Note: Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
Sets the type of the item at the specified index idx to radio button. If false, sets the type of the item to plain text.
Sets the tooltip of the item at the specified index idx.
Sets a for the specified item idx.
Sets the state of a multistate item. See for details.
Disables the of the specified index idx.
Toggles the check state of the item of the specified index idx.
Cycle to the next state of a multistate item. See for details.
Returns the text of the item at index idx.
Returns the icon of the item at index idx.
Returns true if the item at index idx is checked.
Returns the id of the item at index idx. id can be manually assigned, while index can not.
Returns the index of the item containing the specified id. Index is automatically assigned to each item by the engine. Index can not be set manually.
Returns the accelerator of the item at index idx. Accelerators are special combinations of keys that activate the item, no matter which control is focused.
Returns the metadata of the specified item, which might be of any type. You can set it with , which provides a simple way of assigning context data to items.
Returns true if the item at index idx is disabled. When it is disabled it can't be selected, or its action invoked.
See for more info on how to disable an item.
Returns the submenu name of the item at index idx. See for more info on how to add a submenu.
Returns true if the item is a separator. If it is, it will be displayed as a line. See for more info on how to add a separator.
Returns true if the item at index idx is checkable in some way, i.e. if it has a checkbox or radio button.
Note: Checkable items just display a checkmark or radio button, but don't have any built-in checking behavior and must be checked/unchecked manually.
Returns true if the item at index idx has radio button-style checkability.
Note: This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
Returns true if the specified item's shortcut is disabled.
Returns the tooltip associated with the specified index idx.
Returns the associated with the specified idx item.
Sets the currently focused item as the given index.
Passing -1 as the index makes so that no item is focused.
Returns the index of the currently focused item. Returns -1 if no item is focused.
Returns the number of items in the .
Removes the item at index idx from the menu.
Note: The indices of items after the removed item will be shifted by one.
Adds a separator between items. Separators also occupy an index, which you can set by using the id parameter.
A label can optionally be provided, which will appear at the center of the separator.
Removes all items from the .
Hides the when the window loses focus.
Returns true if the popup will be hidden when the window loses focus or not.
Class for displaying popups with a panel background. In some cases it might be simpler to use than , since it provides a configurable background. If you are making windows, better check .
If any node is added as a child of this , it will be stretched to fit the panel's size (similar to how works).
s are a special type of that allow the portal culling system to 'see' from one room to the next. They often correspond to doors and windows in level geometry. By only allowing s to see through portals, this allows the system to cull out all the objects in rooms that cannot be seen through portals. This is a form of occlusion culling, and can greatly increase performance.
There are some limitations to the form of portals:
They must be single sided convex polygons, and usually you would orientate their front faces outward from the they are placed in. The vertices should be positioned on a single plane (although their positioning does not have to be perfect).
There is no need to place an opposite portal in an adjacent room, links are made two-way automatically.
Visibility through s can be turned on and off at runtime - this is useful for having closable doors.
Portals default to being two way - see through in both directions, however you can make them one way, visible from the source room only.
This is a shortcut for setting the linked in the name of the (the name is used during conversion).
In most cases you will want to use the default margin in your portals (this is set in the ).
If you want to override this default, set this value to false, and the local will take effect.
Some objects are so big that they may be present in more than one ('sprawling'). As we often don't want objects that *just* breach the edges to be assigned to neighbouring rooms, you can assign an extra margin through the to allow objects to breach without sprawling.
The points defining the shape of the polygon (which should be convex).
These are defined in 2D, with 0,0 being the origin of the node's .
Note: These raw points are sanitized for winding order internally.
Sets individual points. Primarily for use by the editor.
Generic 2D position hint for editing. It's just like a plain , but it displays as a cross in the 2D editor at all times. You can set cross' visual size by using the gizmo in the 2D editor while the node is selected.
Generic 3D position hint for editing. It's just like a plain , but it displays as a cross in the 3D editor at all times.
Base class for all primitive meshes. Handles applying a to a primitive mesh. Examples include , , , , , , and .
The current of the primitive mesh.
Overrides the with one defined by user for use with frustum culling. Especially useful to avoid unexpected culling when using a shader to offset vertices.
If set, the order of the vertices in each triangle are reversed resulting in the backside of the mesh being drawn.
This gives the same result as using in .
Returns mesh arrays used to constitute surface of . The result can be passed to to create a new surface. For example:
var c := CylinderMesh.new()
var arr_mesh := ArrayMesh.new()
arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, c.get_mesh_arrays())
Class representing a prism-shaped .
Displacement of the upper edge along the X axis. 0.0 positions edge straight above the bottom-left edge.
Size of the prism.
Number of added edge loops along the X axis.
Number of added edge loops along the Y axis.
Number of added edge loops along the Z axis.
ProceduralSky provides a way to create an effective background quickly by defining procedural parameters for the sun, the sky and the ground. The sky and ground are very similar, they are defined by a color at the horizon, another color, and finally an easing curve to interpolate between these two colors. Similarly, the sun is described by a position in the sky, a color, and an easing curve. However, the sun also defines a minimum and maximum angle, these two values define at what distance the easing curve begins and ends from the sun, and thus end up defining the size of the sun in the sky.
The ProceduralSky is updated on the CPU after the parameters change. It is stored in a texture and then displayed as a background in the scene. This makes it relatively unsuitable for real-time updates during gameplay. However, with a small enough texture size, it can still be updated relatively frequently, as it is updated on a background thread when multi-threading is available.
Sky texture will be 256x128.
Sky texture will be 512x256.
Sky texture will be 1024x512. This is the default size.
Sky texture will be 2048x1024.
Sky texture will be 4096x2048.
Represents the size of the enum.
Color of the sky at the top.
Color of the sky at the horizon.
How quickly the fades into the .
Amount of energy contribution from the sky.
Color of the ground at the bottom.
Color of the ground at the horizon.
How quickly the fades into the .
Amount of energy contribution from the ground.
The sun's color.
The sun's height using polar coordinates.
The direction of the sun using polar coordinates.
Distance from sun where it goes from solid to starting to fade.
Distance from center of sun where it fades out completely.
How quickly the sun fades away between and .
Amount of energy contribution from the sun.
Size of that the ProceduralSky will generate. The size is set using .
General-purpose progress bar. Shows fill percentage from right to left.
If true, the fill percentage is displayed on the bar.
Contains global variables accessible from everywhere. Use , or to access them. Variables stored in project.godot are also loaded into ProjectSettings, making this object very useful for reading custom game configuration options.
When naming a Project Settings property, use the full path to the setting including the category. For example, "application/config/name" for the project name. Category and property names can be viewed in the Project Settings dialog.
Feature tags: Project settings can be overridden for specific platforms and configurations (debug, release, ...) using feature tags.
Overriding: Any project setting can be overridden by creating a file named override.cfg in the project's root directory. This can also be used in exported projects by placing this file in the same directory as the project binary. Overriding will still take the base project settings' feature tags in account. Therefore, make sure to also override the setting with the desired feature tags if you want them to override base project settings on all platforms and configurations.
Returns true if a configuration value is present.
Sets the value of a setting.
Example:
ProjectSettings.set_setting("application/config/name", "Example")
This can also be used to erase custom project settings. To do this change the setting value to null.
Returns the value of a setting.
Example:
print(ProjectSettings.get_setting("application/config/name"))
Sets the order of a configuration value (influences when saved to the config file).
Returns the order of a configuration value (influences when saved to the config file).
Sets the specified property's initial value. This is the value the property reverts to.
Adds a custom property info to a property. The dictionary must contain:
- name: (the property's name)
- type: (see )
- optionally hint: (see ) and hint_string:
Example:
ProjectSettings.set("category/property_name", 0)
var property_info = {
"name": "category/property_name",
"type": TYPE_INT,
"hint": PROPERTY_HINT_ENUM,
"hint_string": "one,two,three"
}
ProjectSettings.add_property_info(property_info)
Clears the whole configuration (not recommended, may break things).
Returns the localized path (starting with res://) corresponding to the absolute, native OS path. See also .
Returns the absolute, native OS path corresponding to the localized path (starting with res:// or user://). The returned path will vary depending on the operating system and user preferences. See File paths in Godot projects to see what those paths convert to. See also .
Note: with res:// will not work in an exported project. Instead, prepend the executable's base directory to the path when running from an exported project:
var path = ""
if OS.has_feature("editor"):
# Running from an editor binary.
# `path` will contain the absolute path to `hello.txt` located in the project root.
path = ProjectSettings.globalize_path("res://hello.txt")
else:
# Running from an exported project.
# `path` will contain the absolute path to `hello.txt` next to the executable.
# This is *not* identical to using `ProjectSettings.globalize_path()` with a `res://` path,
# but is close enough in spirit.
path = OS.get_executable_path().get_base_dir().plus_file("hello.txt")
Saves the configuration to the project.godot file.
Note: This method is intended to be used by editor plugins, as modified can't be loaded back in the running app. If you want to change project settings in exported projects, use to save override.cfg file.
Loads the contents of the .pck or .zip file specified by pack into the resource filesystem (res://). Returns true on success.
Note: If a file from pack shares the same path as a file already in the resource filesystem, any attempts to load that file will use the file from pack unless replace_files is set to false.
Note: The optional offset parameter can be used to specify the offset in bytes to the start of the resource pack. This is only supported for .pck files.
Returns true if the specified property exists and its initial value differs from the current value.
Returns the specified property's initial value. Returns null if the property does not exist.
Saves the configuration to a custom file. The file extension must be .godot (to save in text-based format) or .binary (to save in binary format). You can also save override.cfg file, which is also text, but can be used in exported projects unlike other formats.
is used to interpolate a property in an object. See for more usage information.
Note: is the only correct way to create . Any created manually will not function correctly.
Sets a custom initial value to the . Example:
var tween = get_tree().create_tween()
tween.tween_property(self, "position", Vector2(200, 100), 1).from(Vector2(100, 100) #this will move the node from position (100, 100) to (200, 100)
Makes the use the current property value (i.e. at the time of creating this ) as a starting point. This is equivalent of using with the current value. These two calls will do the same:
tween.tween_property(self, "position", Vector2(200, 100), 1).from(position)
tween.tween_property(self, "position", Vector2(200, 100), 1).from_current()
When called, the final value will be used as a relative value instead. Example:
var tween = get_tree().create_tween()
tween.tween_property(self, "position", Vector2.RIGHT * 100, 1).as_relative() #the node will move by 100 pixels to the right
Sets the type of used transition from . If not set, the default transition is used from the that contains this Tweener.
Sets the type of used easing from . If not set, the default easing is used from the that contains this Tweener.
Sets the time in seconds after which the will start interpolating. By default there's no delay.
General-purpose proximity detection node. can be used for approximate distance checks, which are faster than exact distance checks using Vector3.distance_to or Vector3.distance_squared_to.
nodes are automatically grouped together, as long as they share the same and intersect with each other. By calling the , you can invoke a specified method with various parameters to all intersecting members.
is cuboid-shaped and consists of a cluster of coordinates. The coordinates are automatically calculated by calling . To allow to find its peers (and perform automatic grouping), you need to define its to a non-empty . As soon as this object's shape intersects with another object' shape, and both share the same , they will belong together for as long as they intersect.
Since doesn't rely the physics engine, you don't need to add any other node as a child (unlike ).
The uses the groups in the background by calling the method internally. The group names are constructed by combining the with its coordinates, which are calculated using the you defined beforehand.
Example: A node named "PlanetEarth" at position Vector3(6, 6, 6) with a set to "planets" and a of Vector3(1, 2, 3) will create the following group names:
- "planets|5|4|3"
- "planets|5|4|4"
- "planets|5|4|5"
- "planets|5|4|6"
- "planets|5|4|7"
- "planets|5|4|8"
- "planets|5|4|9"
- ...
If there is another named "PlanetMars" with group name "planets", and one of its coordinates is Vector3(5, 4, 7), it would normally create the group called "planets|5|4|7". However, since this group name already exists, this object will be added to the existing one. "PlanetEarth" is already in this group. As long as both nodes don't change their transform and stop intersecting (or exit the scene tree), they are grouped together. As long as this intersection exists, any call to will affect both nodes.
There are 3 caveats to keep in mind when using :
- The larger the grid radius, the more coordinates and the more groups are created. This can have a performance impact if too many groups are created.
- If the node is transformed in any way (or is removed from the scene tree), the groupings will have to be recalculated. This can also have a performance impact.
- If your is smaller than Vector3(1, 1, 1), it will be rounded up to Vector3(1, 1, 1). Therefore, small grid radius values may lead to unwanted groupings.
Note: will be removed in Godot 4.0 in favor of more effective and faster functionality. For most use cases, Vector3.distance_to or Vector3.distance_squared_to are fast enough too, especially if you call them less often using a node.
This 's parent will be target of .
This will emit the broadcast signal when calling the method.
Specify the common group name, to let other nodes know, if they should be auto-grouped with this node in case they intersect with each other.
For example, if you have a node named "Earth" and another called "Mars", with both nodes having "planet" as their . Give both planets a significantly larger than their actual radius, position them close enough and they'll be automatically grouped.
Specifies which node gets contacted on a call of method .
The size of the space in 3D units. This also sets the amount of coordinates required to calculate whether two nodes are intersecting or not. Smaller values can be used for more precise proximity checks at the cost of performance, since more groups will be created.
Calls on all intersecting the given method and parameters.
If the is set to (the default), all calls are delegated to their respective parent .
Class representing a square . This flat mesh does not have a thickness. By default, this mesh is aligned on the X and Y axes; this default rotation is more suited for use with billboarded materials. Unlike , this mesh doesn't provide subdivision options.
Size on the X and Y axes.
Offset of the generated Quad. Useful for particles.
RandomNumberGenerator is a class for generating pseudo-random numbers. It currently uses PCG32.
Note: The underlying algorithm is an implementation detail. As a result, it should not be depended upon for reproducible random streams across Godot versions.
To generate a random float number (within a given range) based on a time-dependant seed:
var rng = RandomNumberGenerator.new()
func _ready():
rng.randomize()
var my_random_number = rng.randf_range(-10.0, 10.0)
Note: The default values of and properties are pseudo-random, and changes when calling . The 0 value documented here is a placeholder, and not the actual default seed.
Initializes the random number generator state based on the given seed value. A given seed will give a reproducible sequence of pseudo-random numbers.
Note: The RNG does not have an avalanche effect, and can output similar random streams given similar seeds. Consider using a hash function to improve your seed quality if they're sourced externally.
Note: Setting this property produces a side effect of changing the internal , so make sure to initialize the seed before modifying the :
var rng = RandomNumberGenerator.new()
rng.seed = hash("Godot")
rng.state = 100 # Restore to some previously saved state.
Warning: the getter of this property returns the previous , and not the initial seed value, which is going to be fixed in Godot 4.0.
The current state of the random number generator. Save and restore this property to restore the generator to a previous state:
var rng = RandomNumberGenerator.new()
print(rng.randf())
var saved_state = rng.state # Store current state.
print(rng.randf()) # Advance internal state.
rng.state = saved_state # Restore the state.
print(rng.randf()) # Prints the same value as in previous.
Note: Do not set state to arbitrary values, since the random number generator requires the state to have certain qualities to behave properly. It should only be set to values that came from the state property itself. To initialize the random number generator with arbitrary input, use instead.
Generates a pseudo-random 32-bit unsigned integer between 0 and 4294967295 (inclusive).
Generates a pseudo-random float between 0.0 and 1.0 (inclusive).
Generates a normally-distributed pseudo-random number, using Box-Muller transform with the specified mean and a standard deviation. This is also called Gaussian distribution.
Generates a pseudo-random float between from and to (inclusive).
Generates a pseudo-random 32-bit signed integer between from and to (inclusive).
Setups a time-based seed to generator.
Range is a base class for nodes that change a floating-point between a and , using a configured and size. See e.g. and for examples of higher level nodes using Range.
Minimum value. Range is clamped if value is less than min_value.
Maximum value. Range is clamped if value is greater than max_value.
If greater than 0, value will always be rounded to a multiple of step. If rounded is also true, value will first be rounded to a multiple of step then rounded to the nearest integer.
Page size. Used mainly for . ScrollBar's length is its size multiplied by page over the difference between min_value and max_value.
Range's current value.
The value mapped between 0 and 1.
If true, and min_value is greater than 0, value will be represented exponentially rather than linearly.
If true, value will always be rounded to the nearest integer.
If true, may be greater than .
If true, may be less than .
Binds two s together along with any ranges previously grouped with either of them. When any of range's member variables change, it will share the new value with all other ranges in its group.
Stops the from sharing its member variables with any other.
A RayCast represents a line from its origin to its destination position, cast_to. It is used to query the 3D space in order to find the closest object along the path of the ray.
RayCast can ignore some objects by adding them to the exception list via add_exception or by setting proper filtering with collision layers and masks.
RayCast can be configured to report collisions with s () and/or s ().
Only enabled raycasts will be able to query the space and report collisions.
RayCast calculates intersection every physics frame (see ), and the result is cached so it can be used later until the next frame. If multiple queries are required between physics frames (or during the same frame), use after adjusting the raycast.
If true, collisions will be reported.
If true, collisions will be ignored for this RayCast's immediate parent.
The ray's destination point, relative to the RayCast's position.
The ray's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. See Collision layers and masks in the documentation for more information.
If true, collision with s will be reported.
If true, collision with s will be reported.
The custom color to use to draw the shape in the editor and at run-time if Visible Collision Shapes is enabled in the Debug menu. This color will be highlighted at run-time if the is colliding with something.
If set to Color(0.0, 0.0, 0.0) (by default), the color set in is used.
If set to 1, a line is used as the debug shape. Otherwise, a truncated pyramid is drawn to represent the . Requires Visible Collision Shapes to be enabled in the Debug menu for the debug shape to be visible at run-time.
Returns whether any object is intersecting with the ray's vector (considering the vector length).
Updates the collision information for the ray. Use this method to update the collision information immediately instead of waiting for the next _physics_process call, for example if the ray or its parent has changed state.
Note: enabled is not required for this to work.
Returns the first object that the ray intersects, or null if no object is intersecting the ray (i.e. returns false).
Returns the shape ID of the first object that the ray intersects, or 0 if no object is intersecting the ray (i.e. returns false).
Returns the collision point at which the ray intersects the closest object.
Note: This point is in the global coordinate system.
Returns the normal of the intersecting object's shape at the collision point.
Adds a collision exception so the ray does not report collisions with the specified .
Adds a collision exception so the ray does not report collisions with the specified node.
Removes a collision exception so the ray does report collisions with the specified .
Removes a collision exception so the ray does report collisions with the specified node.
Removes all collision exceptions for this ray.
Sets the bit index passed to the value passed.
Note: Bit indexes range from 0-19.
Returns true if the bit index passed is turned on.
Note: Bit indices range from 0-19.
A RayCast represents a line from its origin to its destination position, cast_to. It is used to query the 2D space in order to find the closest object along the path of the ray.
RayCast2D can ignore some objects by adding them to the exception list via add_exception, by setting proper filtering with collision layers, or by filtering object types with type masks.
RayCast2D can be configured to report collisions with s () and/or s ().
Only enabled raycasts will be able to query the space and report collisions.
RayCast2D calculates intersection every physics frame (see ), and the result is cached so it can be used later until the next frame. If multiple queries are required between physics frames (or during the same frame) use after adjusting the raycast.
If true, collisions will be reported.
If true, the parent node will be excluded from collision detection.
The ray's destination point, relative to the RayCast's position.
The ray's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. See Collision layers and masks in the documentation for more information.
If true, collision with s will be reported.
If true, collision with s will be reported.
Returns whether any object is intersecting with the ray's vector (considering the vector length).
Updates the collision information for the ray. Use this method to update the collision information immediately instead of waiting for the next _physics_process call, for example if the ray or its parent has changed state.
Note: enabled is not required for this to work.
Returns the first object that the ray intersects, or null if no object is intersecting the ray (i.e. returns false).
Returns the shape ID of the first object that the ray intersects, or 0 if no object is intersecting the ray (i.e. returns false).
Returns the collision point at which the ray intersects the closest object.
Note: This point is in the global coordinate system.
Returns the normal of the intersecting object's shape at the collision point.
Adds a collision exception so the ray does not report collisions with the specified .
Adds a collision exception so the ray does not report collisions with the specified node.
Removes a collision exception so the ray does report collisions with the specified .
Removes a collision exception so the ray does report collisions with the specified node.
Removes all collision exceptions for this ray.
Sets or clears individual bits on the collision mask. This makes selecting the areas scanned easier.
Returns an individual bit on the collision mask.
Ray shape for 3D collisions, which can be set into a or . A ray is not really a collision body; instead, it tries to separate itself from whatever is touching its far endpoint. It's often useful for characters.
The ray's length.
If true, allow the shape to return the correct normal.
Ray shape for 2D collisions. A ray is not really a collision body; instead, it tries to separate itself from whatever is touching its far endpoint. It's often useful for characters.
The ray's length.
If true, allow the shape to return the correct normal.
Rectangle shape for 2D collisions. This shape is useful for modeling box-like 2D objects.
The rectangle's half extents. The width and height of this shape is twice the half extents.
Base class for any object that keeps a reference count. and many other helper objects inherit this class.
Unlike other types, References keep an internal reference counter so that they are automatically released when no longer in use, and only then. References therefore do not need to be freed manually with .
In the vast majority of use cases, instantiating and using -derived types is all you need to do. The methods provided in this class are only for advanced users, and can cause issues if misused.
Note: In C#, references will not be freed instantly after they are no longer in use. Instead, garbage collection will run periodically and will free references that are no longer in use. This means that unused references will linger on for a while before being removed.
Initializes the internal reference counter. Use this only if you really know what you are doing.
Returns whether the initialization was successful.
Increments the internal reference counter. Use this only if you really know what you are doing.
Returns true if the increment was successful, false otherwise.
Decrements the internal reference counter. Use this only if you really know what you are doing.
Returns true if the decrement was successful, false otherwise.
A rectangle box that displays only a border color around its rectangle. has no fill . If you need to display a rectangle filled with a solid color, consider using instead.
Sets the border of the .
Sets the border width of the . The border grows both inwards and outwards with respect to the rectangle box.
If set to true, the will only be visible while in editor. Otherwise, will be visible in game.
Capture its surroundings as a dual paraboloid image, and stores versions of it with increasing levels of blur to simulate different material roughnesses.
The is used to create high-quality reflections at a low performance cost (when is ). s can be blended together and with the rest of the scene smoothly. s can also be combined with and screen-space reflections () to get more accurate reflections in specific areas. s render all objects within their , so updating them can be quite expensive. It is best to update them once with the important static objects and then leave them as-is.
Note: Unlike , s only source their environment from a node. If you specify an resource within a node, it will be ignored by the . This can lead to incorrect lighting within the .
Note: By default, Godot will only render 16 reflection probes. If you need more, increase the number of atlas subdivisions. This setting can be found in .
Note: The GLES2 backend will only display two reflection probes at the same time for a single mesh. If possible, split up large meshes that span over multiple reflection probes into smaller ones.
Update the probe once on the next frame (recommended for most objects). The corresponding radiance map will be generated over the following six frames. This takes more time to update than , but it has a lower performance cost and can result in higher-quality reflections. The ReflectionProbe is updated when its transform changes, but not when nearby geometry changes. You can force a update by moving the slightly in any direction.
Update the probe every frame. This provides better results for fast-moving dynamic objects (such as cars). However, it has a significant performance cost. Due to the cost, it's recommended to only use one ReflectionProbe with at most per scene. For all other use cases, use .
Sets how frequently the is updated. Can be or .
Defines the reflection intensity. Intensity modulates the strength of the reflection.
The maximum distance away from the an object can be before it is culled. Decrease this to improve performance, especially when using the .
Note: The maximum reflection distance is always at least equal to the . This means that decreasing will not always cull objects from reflections, especially if the reflection probe's are already large.
The size of the reflection probe. The larger the extents the more space covered by the probe which will lower the perceived resolution. It is best to keep the extents only as large as you need them.
Note: To better fit areas that are not aligned to the grid, you can rotate the node.
Sets the origin offset to be used when this is in mode. This can be set to a non-zero value to ensure a reflection fits a rectangle-shaped room, while reducing the amount of objects that "get in the way" of the reflection.
If true, enables box projection. This makes reflections look more correct in rectangle-shaped rooms by offsetting the reflection center depending on the camera's location.
Note: To better fit rectangle-shaped rooms that are not aligned to the grid, you can rotate the node.
If true, computes shadows in the reflection probe. This makes the reflection probe slower to render; you may want to disable this if using the .
Sets the cull mask which determines what objects are drawn by this probe. Every with a layer included in this cull mask will be rendered by the probe. To improve performance, it is best to only include large objects which are likely to take up a lot of space in the reflection.
If true, reflections will ignore sky contribution. Ambient lighting is then controlled by the interior_ambient_* properties.
Sets the ambient light color to be used when this probe is set to .
Sets the energy multiplier for this reflection probe's ambient light contribution when set to .
Sets the contribution value for how much the reflection affects the ambient light for this reflection probe when set to . Useful so that ambient light matches the color of the room.
A regular expression (or regex) is a compact language that can be used to recognise strings that follow a specific pattern, such as URLs, email addresses, complete sentences, etc. For instance, a regex of ab[0-9] would find any string that is ab followed by any number from 0 to 9. For a more in-depth look, you can easily find various tutorials and detailed explanations on the Internet.
To begin, the RegEx object needs to be compiled with the search pattern using before it can be used.
var regex = RegEx.new()
regex.compile("\\w-(\\d+)")
The search pattern must be escaped first for GDScript before it is escaped for the expression. For example, compile("\\d+") would be read by RegEx as \d+. Similarly, compile("\"(?:\\\\.|[^\"])*\"") would be read as "(?:\\.|[^"])*".
Using , you can find the pattern within the given text. If a pattern is found, is returned and you can retrieve details of the results using methods such as and .
var regex = RegEx.new()
regex.compile("\\w-(\\d+)")
var result = regex.search("abc n-0123")
if result:
print(result.get_string()) # Would print n-0123
The results of capturing groups () can be retrieved by passing the group number to the various methods in . Group 0 is the default and will always refer to the entire pattern. In the above example, calling result.get_string(1) would give you 0123.
This version of RegEx also supports named capturing groups, and the names can be used to retrieve the results. If two or more groups have the same name, the name would only refer to the first one with a match.
var regex = RegEx.new()
regex.compile("d(?<digit>[0-9]+)|x(?<digit>[0-9a-f]+)")
var result = regex.search("the number is x2f")
if result:
print(result.get_string("digit")) # Would print 2f
If you need to process multiple results, generates a list of all non-overlapping results. This can be combined with a for loop for convenience.
for result in regex.search_all("d01, d03, d0c, x3f and x42"):
print(result.get_string("digit"))
# Would print 01 03 0 3f 42
Example of splitting a string using a RegEx:
var regex = RegEx.new()
regex.compile("\\S+") # Negated whitespace character class.
var results = []
for result in regex.search_all("One Two \n\tThree"):
results.push_back(result.get_string())
# The `results` array now contains "One", "Two", "Three".
Note: Godot's regex implementation is based on the PCRE2 library. You can view the full pattern reference here.
Tip: You can use Regexr to test regular expressions online.
This method resets the state of the object, as if it was freshly created. Namely, it unassigns the regular expression of this object.
Compiles and assign the search pattern to use. Returns OK if the compilation is successful. If an error is encountered, details are printed to standard output and an error is returned.
Searches the text for the compiled pattern. Returns a container of the first matching result if found, otherwise null. The region to search within can be specified without modifying where the start and end anchor would be.
Searches the text for the compiled pattern. Returns an array of containers for each non-overlapping result. If no results were found, an empty array is returned instead. The region to search within can be specified without modifying where the start and end anchor would be.
Searches the text for the compiled pattern and replaces it with the specified string. Escapes and backreferences such as $1 and $name are expanded and resolved. By default, only the first instance is replaced, but it can be changed for all instances (global replacement). The region to search within can be specified without modifying where the start and end anchor would be.
Returns whether this object has a valid search pattern assigned.
Returns the original search pattern that was compiled.
Returns the number of capturing groups in compiled pattern.
Returns an array of names of named capturing groups in the compiled pattern. They are ordered by appearance.
Contains the results of a single match returned by and . It can be used to find the position and range of the match and its capturing groups, and it can extract its substring for you.
The source string used with the search pattern to find this matching result.
A dictionary of named groups and its corresponding group number. Only groups that were matched are included. If multiple groups have the same name, that name would refer to the first matching one.
An of the match and its capturing groups.
Returns the number of capturing groups.
Returns the substring of the match from the source string. Capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern.
Returns an empty string if the group did not match or doesn't exist.
If the parameter is null, then the default value is (object)0
Returns the starting position of the match within the source string. The starting position of capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern.
Returns -1 if the group did not match or doesn't exist.
If the parameter is null, then the default value is (object)0
Returns the end position of the match within the source string. The end position of capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern.
Returns -1 if the group did not match or doesn't exist.
If the parameter is null, then the default value is (object)0
RemoteTransform pushes its own to another derived Node (called the remote node) in the scene.
It can be set to update another Node's position, rotation and/or scale. It can use either global or local coordinates.
The to the remote node, relative to the RemoteTransform's position in the scene.
If true, global coordinates are used. If false, local coordinates are used.
If true, the remote node's position is updated.
If true, the remote node's rotation is updated.
If true, the remote node's scale is updated.
caches the remote node. It may not notice if the remote node disappears; forces it to update the cache again.
RemoteTransform2D pushes its own to another derived Node (called the remote node) in the scene.
It can be set to update another Node's position, rotation and/or scale. It can use either global or local coordinates.
The to the remote node, relative to the RemoteTransform2D's position in the scene.
If true, global coordinates are used. If false, local coordinates are used.
If true, the remote node's position is updated.
If true, the remote node's rotation is updated.
If true, the remote node's scale is updated.
caches the remote node. It may not notice if the remote node disappears; forces it to update the cache again.
Resource is the base class for all Godot-specific resource types, serving primarily as data containers. Since they inherit from , resources are reference-counted and freed when no longer in use. They are also cached once loaded from disk, so that any further attempts to load a resource from a given path will return the same reference (all this in contrast to a , which is not reference-counted and can be instanced from disk as many times as desired). Resources can be saved externally on disk or bundled into another object, such as a or another resource.
Note: In C#, resources will not be freed instantly after they are no longer in use. Instead, garbage collection will run periodically and will free resources that are no longer in use. This means that unused resources will linger on for a while before being removed.
If true, the resource will be made unique in each instance of its local scene. It can thus be modified in a scene instance without impacting other instances of that same scene.
The path to the resource. In case it has its own file, it will return its filepath. If it's tied to the scene, it will return the scene's path, followed by the resource's index.
The name of the resource. This is an optional identifier. If is not empty, its value will be displayed to represent the current resource in the editor inspector. For built-in scripts, the will be displayed as the tab name in the script editor.
Virtual function which can be overridden to customize the behavior value of .
Sets the path of the resource, potentially overriding an existing cache entry for this path. This differs from setting , as the latter would error out if another resource was already cached for the given path.
Returns the RID of the resource (or an empty RID). Many resources (such as , , etc) are high-level abstractions of resources stored in a server, so this function will return the original RID.
If is enabled and the resource was loaded from a instantiation, returns the local scene where this resource's unique copy is in use. Otherwise, returns null.
This method is called when a resource with enabled is loaded from a instantiation. Its behavior can be customized by overriding from script.
For most resources, this method performs no base logic. performs custom logic to properly set the proxy texture and flags in the local viewport.
Emits the changed signal.
If external objects which depend on this resource should be updated, this method must be called manually whenever the state of this resource has changed (such as modification of properties).
The method is equivalent to:
emit_signal("changed")
Note: This method is called automatically for built-in resources.
Duplicates the resource, returning a new resource with the exported members copied. Note: To duplicate the resource the constructor is called without arguments. This method will error when the constructor doesn't have default values.
By default, sub-resources are shared between resource copies for efficiency. This can be changed by passing true to the subresources argument which will copy the subresources.
Note: If subresources is true, this method will only perform a shallow copy. Nested resources within subresources will not be duplicated and will still be shared.
Note: When duplicating a resource, only exported properties are copied. Other properties will be set to their default value in the new resource.
Godot loads resources in the editor or in exported games using ResourceFormatLoaders. They are queried automatically via the singleton, or when a resource with internal dependencies is loaded. Each file type may load as a different resource type, so multiple ResourceFormatLoaders are registered in the engine.
Extending this class allows you to define your own loader. Be sure to respect the documented return types and values. You should give it a global class name with class_name for it to be registered. Like built-in ResourceFormatLoaders, it will be called automatically when loading resources of its handled type(s). You may also implement a .
Note: You can also extend if the resource type you need exists but Godot is unable to load its format. Choosing one way over another depends on if the format is suitable or not for the final exported game. For example, it's better to import .png textures as .stex () first, so they can be loaded with better efficiency on the graphics card.
If implemented, gets the dependencies of a given resource. If add_types is true, paths should be appended ::TypeName, where TypeName is the class name of the dependency.
Note: Custom resource types defined by scripts aren't known by the , so you might just return "Resource" for them.
Gets the list of extensions for files this loader is able to read.
Gets the class name of the resource associated with the given path. If the loader cannot handle it, it should return "".
Note: Custom resource types defined by scripts aren't known by the , so you might just return "Resource" for them.
Tells which resource class this loader can load.
Note: Custom resource types defined by scripts aren't known by the , so you might just handle "Resource" for them.
Loads a resource when the engine finds this loader to be compatible. If the loaded resource is the result of an import, original_path will target the source file. Returns a object on success, or an constant in case of failure.
If implemented, renames dependencies within the given resource and saves it. renames is a dictionary { String => String } mapping old dependency paths to new paths.
Returns OK on success, or an constant in case of failure.
The engine can save resources when you do it from the editor, or when you use the singleton. This is accomplished thanks to multiple s, each handling its own format and called automatically by the engine.
By default, Godot saves resources as .tres (text-based), .res (binary) or another built-in format, but you can choose to create your own format by extending this class. Be sure to respect the documented return types and values. You should give it a global class name with class_name for it to be registered. Like built-in ResourceFormatSavers, it will be called automatically when saving resources of its recognized type(s). You may also implement a .
Returns the list of extensions available for saving the resource object, provided it is recognized (see ).
Returns whether the given resource object can be saved by this saver.
Saves the given resource object to a file at the target path. flags is a bitmask composed with constants.
Returns OK on success, or an constant in case of failure.
This is the base class for the resource importers implemented in core. To implement your own resource importers using editor plugins, see .
The default import order.
The import order for scenes, which ensures scenes are imported after all other core resources such as textures. Custom importers should generally have an import order lower than 100 to avoid issues when importing scenes that rely on custom resources.
Interactive loader. This object is returned by when performing an interactive load. It allows loading resources with high granularity, which makes it mainly useful for displaying loading bars or percentages.
Returns the loaded resource if the load operation completed successfully, null otherwise.
Polls the loading operation, i.e. loads a data chunk up to the next stage.
Returns OK if the poll is successful but the load operation has not finished yet (intermediate stage). This means will have to be called again until the last stage is completed.
Returns ERR_FILE_EOF if the load operation has completed successfully. The loaded resource can be obtained by calling .
Returns another code if the poll has failed.
Polls the loading operation successively until the resource is completely loaded or a fails.
Returns ERR_FILE_EOF if the load operation has completed successfully. The loaded resource can be obtained by calling .
Returns another code if a poll has failed, aborting the operation.
Returns the load stage. The total amount of stages can be queried with .
Returns the total amount of stages (calls to ) needed to completely load this resource.
This node is used to preload sub-resources inside a scene, so when the scene is loaded, all the resources are ready to use and can be retrieved from the preloader.
GDScript has a simplified @GDScript.preload built-in method which can be used in most situations, leaving the use of for more advanced scenarios.
Adds a resource to the preloader with the given name. If a resource with the given name already exists, the new resource will be renamed to "name N" where N is an incrementing number starting from 2.
Removes the resource associated to name from the preloader.
Renames a resource inside the preloader from name to newname.
Returns true if the preloader contains a resource associated to name.
Returns the resource associated to name.
Returns the list of resources inside the preloader.
A custom effect for use with .
Note: For a to be usable, a BBCode tag must be defined as a member variable called bbcode in the script.
# The RichTextEffect will be usable like this: `[example]Some text[/example]`
var bbcode = "example"
Note: As soon as a contains at least one , it will continuously process the effect unless the project is paused. This may impact battery life negatively.
Override this method to modify properties in char_fx. The method must return true if the character could be transformed successfully. If the method returns false, it will skip transformation to avoid displaying broken text.
Rich text can contain custom text, fonts, images and some basic formatting. The label manages these as an internal tag stack. It also adapts itself to given width/heights.
Note: Assignments to clear the tag stack and reconstruct it from the property's contents. Any edits made to will erase previous edits made from other manual sources such as and the push_* / methods.
Note: RichTextLabel doesn't support entangled BBCode tags. For example, instead of using [b]bold[i]bold italic[/b]italic[/i], use [b]bold[i]bold italic[/i][/b][i]italic[/i].
Note: push_*/pop functions won't affect BBCode.
Note: Unlike , RichTextLabel doesn't have a property to horizontally align text to the center. Instead, enable and surround the text in a [center] tag as follows: [center]Example[/center]. There is currently no built-in way to vertically align text either, but this can be emulated by relying on anchors/containers and the property.
Note: Unicode characters after 0xffff (such as most emoji) are not supported on Windows. They will display as unknown characters instead. This will be resolved in Godot 4.0.
Makes text left aligned.
Makes text centered.
Makes text right aligned.
Makes text fill width.
Each list item has a number marker.
Each list item has a letter marker.
Each list item has a filled circle marker.
Aligns top of the inline image to the top of the text.
Aligns center of the inline image to the center of the text.
Aligns bottom of the inline image to the baseline of the text.
Aligns bottom of the inline image to the bottom of the text.
If true, the label uses BBCode formatting.
Note: Trying to alter the 's text with will reset this to false. Use instead to preserve BBCode formatting.
The label's text in BBCode format. Is not representative of manual modifications to the internal tag stack. Erases changes made by other methods when edited.
Note: It is unadvised to use the += operator with bbcode_text (e.g. bbcode_text += "some string") as it replaces the whole text and can cause slowdowns. It will also erase all BBCode that was added to stack using push_* methods. Use for adding text instead, unless you absolutely need to close a tag that was opened in an earlier method call.
The restricted number of characters to display in the label. If -1, all characters will be displayed.
Note: Setting this property updates based on current .
The range of characters to display, as a between 0.0 and 1.0. When assigned an out of range value, it's the same as assigning 1.0.
Note: Setting this property updates based on current .
If true, the label underlines meta tags such as [url]{text}[/url].
The number of spaces associated with a single tab length. Does not affect \t in text tags, only indent tags.
The raw text of the label.
When set, clears the tag stack and adds a raw text tag to the top of it. Does not parse BBCodes. Does not modify .
If true, the label's height will be automatically updated to fit its content.
Note: This property is used as a workaround to fix issues with in s, but it's unreliable in some cases and will be removed in future versions.
If true, the scrollbar is visible. Setting this to false does not block scrolling completely. See .
If true, the window scrolls down to display new content automatically.
If true, the label allows text selection.
If true, the label uses the custom font color.
If true, the selected text will be deselected when focus is lost.
The currently installed custom effects. This is an array of s.
To add a custom effect, it's more convenient to use .
Adds raw non-BBCode-parsed text to the tag stack.
Adds an image's opening and closing tags to the tag stack, optionally providing a width and height to resize the image.
If width or height is set to 0, the image size will be adjusted in order to keep the original aspect ratio.
Adds a newline tag to the tag stack.
Removes a line of content from the label. Returns true if the line exists.
The line argument is the index of the line to remove, it can take values in the interval [0, get_line_count() - 1].
Adds a [font] tag to the tag stack. Overrides default fonts for its duration.
Adds a [font] tag with a normal font to the tag stack.
Adds a [font] tag with a bold font to the tag stack. This is the same as adding a [b] tag if not currently in a [i] tag.
Adds a [font] tag with a bold italics font to the tag stack.
Adds a [font] tag with a italics font to the tag stack. This is the same as adding a [i] tag if not currently in a [b] tag.
Adds a [font] tag with a monospace font to the tag stack.
Adds a [color] tag to the tag stack.
Adds an [align] tag based on the given align value. See for possible values.
Adds an [indent] tag to the tag stack. Multiplies level by current to determine new margin length.
Adds a [list] tag to the tag stack. Similar to the BBCodes [ol] or [ul], but supports more list types. Not fully implemented!
Adds a [meta] tag to the tag stack. Similar to the BBCode [url=something]{text}[/url], but supports non- metadata types.
Adds a [u] tag to the tag stack.
Adds a [s] tag to the tag stack.
Adds a [table=columns] tag to the tag stack.
Edits the selected column's expansion options. If expand is true, the column expands in proportion to its expansion ratio versus the other columns' ratios.
For example, 2 columns with ratios 3 and 4 plus 70 pixels in available width would expand 30 and 40 pixels, respectively.
If expand is false, the column will not contribute to the total ratio.
Adds a [cell] tag to the tag stack. Must be inside a [table] tag. See for details.
Terminates the current tag. Use after push_* methods to close BBCodes manually. Does not need to follow add_* methods.
Clears the tag stack and sets to an empty string.
Returns the current selection text. Does not include BBCodes.
Clears the current selection.
Returns the vertical scrollbar.
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Scrolls the window's top line to match line.
The assignment version of . Clears the tag stack and inserts the new content.
Note: This method internals' can't possibly fail, but an error code is returned for backwards compatibility, which will always be OK.
Parses bbcode and adds tags to the tag stack as needed.
Note: Using this method, you can't close a tag that was opened in a previous call. This is done to improve performance, especially when updating large RichTextLabels since rebuilding the whole BBCode every time would be slower. If you absolutely need to close a tag in a future method call, append the instead of using .
Note: This method internals' can't possibly fail, but an error code is returned for backwards compatibility, which will always be OK.
Returns the total number of characters from text tags. Does not include BBCodes.
Returns the total number of newlines in the tag stack's text tags. Considers wrapped text as one line.
Returns the number of visible lines.
Returns the height of the content.
Parses BBCode parameter expressions into a dictionary.
Installs a custom effect. effect should be a valid .
This is the node that implements full 3D physics. This means that you do not control a RigidBody directly. Instead, you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.
A RigidBody has 4 behavior s: Rigid, Static, Character, and Kinematic.
Note: Don't change a RigidBody's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed Hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop may result in strange behavior. If you need to directly affect the body's state, use , which allows you to directly access the physics state.
If you need to override the default physics behavior, you can write a custom force integration function. See .
With Bullet physics (the default), the center of mass is the RigidBody3D center. With GodotPhysics, the center of mass is the average of the centers.
Rigid body mode. This is the "natural" state of a rigid body. It is affected by forces, and can move, rotate, and be affected by user code.
Static mode. The body behaves like a , and can only move by user code.
Character body mode. This behaves like a rigid body, but can not rotate.
Kinematic body mode. The body behaves like a , and can only move by user code.
The body mode. See for possible values.
The body's mass.
The body's weight based on its mass and the global 3D gravity. Global values are set in Project > Project Settings > Physics > 3d.
The body's friction, from 0 (frictionless) to 1 (max friction).
Deprecated, use instead via .
The body's bounciness. Values range from 0 (no bounce) to 1 (full bounciness).
Deprecated, use instead via .
The physics material override for the body.
If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
This is multiplied by the global 3D gravity setting found in Project > Project Settings > Physics > 3d to produce RigidBody's gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
If true, internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the function, if defined.
If true, continuous collision detection is used.
Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. Continuous collision detection is more precise, and misses fewer impacts by small, fast-moving objects. Not using continuous collision detection is faster to compute, but can miss small, fast-moving objects.
The maximum number of contacts that will be recorded. Requires to be set to true.
Note: The number of contacts is different from the number of collisions. Collisions between parallel edges will result in two contacts (one at each end), and collisions between parallel faces will result in four contacts (one at each corner).
If true, the RigidBody will emit signals when it collides with another RigidBody. See also .
If true, the body will not move and will not calculate forces until woken up by another body through, for example, a collision, or by using the or methods.
If true, the body can enter sleep mode when there is no movement. See .
Note: A RigidBody3D will never enter sleep mode automatically if its is . It can still be put to sleep manually by setting its property to true.
Lock the body's movement in the X axis.
Lock the body's movement in the Y axis.
Lock the body's movement in the Z axis.
Lock the body's rotation in the X axis.
Lock the body's rotation in the Y axis.
Lock the body's rotation in the Z axis.
The body's linear velocity in units per second. Can be used sporadically, but don't set this every frame, because physics may run in another thread and runs at a different granularity. Use as your process loop for precise control of the body state.
The body's linear damp. Cannot be less than -1.0. If this value is different from -1.0 it will be added to any linear damp derived from the world or areas.
See for more details about damping.
The body's rotational velocity in axis-angle format. The magnitude of the vector is the rotation rate in radians per second.
Damps the body's rotational forces. If this value is different from -1.0 it will be added to any angular damp derived from the world or areas.
See for more details about damping.
Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it works in addition to the usual physics behavior, but the property allows you to disable the default behavior and do fully custom force integration for a body.
Returns the inverse inertia tensor basis. This is used to calculate the angular acceleration resulting from a torque applied to the RigidBody.
Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.
Adds a constant directional force (i.e. acceleration) without affecting rotation.
This is equivalent to add_force(force, Vector3(0,0,0)).
Adds a constant directional force (i.e. acceleration).
The position uses the rotation of the global coordinate system, but is centered at the object's origin.
Adds a constant rotational force (i.e. a motor) without affecting position.
Applies a directional impulse without affecting rotation.
This is equivalent to apply_impulse(Vector3(0,0,0), impulse).
Applies a positioned impulse to the body. An impulse is time independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts. The position uses the rotation of the global coordinate system, but is centered at the object's origin.
Applies a torque impulse which will be affected by the body mass and shape. This will rotate the body around the impulse vector passed.
Locks the specified linear or rotational axis.
Returns true if the specified linear or rotational axis is locked.
Returns a list of the bodies colliding with this one. Requires to be set to true and to be set high enough to detect all the collisions.
Note: The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead.
This node implements simulated 2D physics. You do not control a RigidBody2D directly. Instead, you apply forces to it (gravity, impulses, etc.) and the physics simulation calculates the resulting movement based on its mass, friction, and other physical properties.
A RigidBody2D has 4 behavior s: Rigid, Static, Character, and Kinematic.
Note: You should not change a RigidBody2D's position or linear_velocity every frame or even very often. If you need to directly affect the body's state, use , which allows you to directly access the physics state.
Please also keep in mind that physics bodies manage their own transform which overwrites the ones you set. So any direct or indirect transformation (including scaling of the node or its parent) will be visible in the editor only, and immediately reset at runtime.
If you need to override the default physics behavior or add a transformation at runtime, you can write a custom force integration. See .
The center of mass is always located at the node's origin without taking into account the centroid offsets.
Rigid mode. The body behaves as a physical object. It collides with other bodies and responds to forces applied to it. This is the default mode.
Static mode. The body behaves like a and does not move.
Character mode. Similar to , but the body can not rotate.
Kinematic mode. The body behaves like a , and must be moved by code.
Continuous collision detection disabled. This is the fastest way to detect body collisions, but can miss small, fast-moving objects.
Continuous collision detection enabled using raycasting. This is faster than shapecasting but less precise.
Continuous collision detection enabled using shapecasting. This is the slowest CCD method and the most precise.
The body's mode. See for possible values.
The body's mass.
The body's moment of inertia. This is like mass, but for rotation: it determines how much torque it takes to rotate the body. The moment of inertia is usually computed automatically from the mass and the shapes, but this function allows you to set a custom value. Set 0 inertia to return to automatically computing it.
The body's weight based on its mass and the Default Gravity value in Project > Project Settings > Physics > 2d.
The body's friction. Values range from 0 (frictionless) to 1 (maximum friction).
Deprecated, use instead via .
The body's bounciness. Values range from 0 (no bounce) to 1 (full bounciness).
Deprecated, use instead via .
The physics material override for the body.
If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
Multiplies the gravity applied to the body. The body's gravity is calculated from the Default Gravity value in Project > Project Settings > Physics > 2d and/or any additional gravity vector applied by s.
If true, internal force integration is disabled for this body. Aside from collision response, the body will only move as determined by the function.
Continuous collision detection mode.
Continuous collision detection tries to predict where a moving body will collide instead of moving it and correcting its movement after collision. Continuous collision detection is slower, but more precise and misses fewer collisions with small, fast-moving objects. Raycasting and shapecasting methods are available. See for details.
The maximum number of contacts that will be recorded. Requires to be set to true.
Note: The number of contacts is different from the number of collisions. Collisions between parallel edges will result in two contacts (one at each end).
If true, the body will emit signals when it collides with another RigidBody2D. See also .
If true, the body will not move and will not calculate forces until woken up by another body through, for example, a collision, or by using the or methods.
If true, the body can enter sleep mode when there is no movement. See .
Note: A RigidBody2D will never enter sleep mode automatically if its is . It can still be put to sleep manually by setting its property to true.
The body's linear velocity in pixels per second. Can be used sporadically, but don't set this every frame, because physics may run in another thread and runs at a different granularity. Use as your process loop for precise control of the body state.
Damps the body's . If -1, the body will use the Default Linear Damp in Project > Project Settings > Physics > 2d. If greater than -1 it will be added to the default project value.
See for more details about damping.
The body's rotational velocity in radians per second.
Damps the body's . If -1, the body will use the Default Angular Damp defined in Project > Project Settings > Physics > 2d. If greater than -1 it will be added to the default project value.
See for more details about damping.
The body's total applied force.
The body's total applied torque.
Allows you to read and safely modify the simulation state for the object. Use this instead of if you need to directly change the body's position or other physics properties. By default, it works in addition to the usual physics behavior, but allows you to disable the default behavior and write custom force integration for a body.
Sets the body's velocity on the given axis. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.
Applies a directional impulse without affecting rotation.
Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts (use the "_force" functions otherwise). The position uses the rotation of the global coordinate system, but is centered at the object's origin.
Applies a rotational impulse to the body.
Adds a constant directional force without affecting rotation.
Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
Adds a constant rotational force.
Returns true if a collision would result from moving in the given vector. margin increases the size of the shapes involved in the collision detection, and result is an object of type , which contains additional information about the collision (should there be one).
Returns a list of the bodies colliding with this one. Requires to be set to true and to be set high enough to detect all the collisions.
Note: The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead.
The culling system requires levels to be built using objects grouped together by location in areas called s. In many cases these will correspond to actual rooms in buildings, but not necessarily (a canyon area may be treated as a room).
Any that is a child or grandchild of a will be assigned to that room, if the portal_mode of that is set to STATIC (does not move) or DYNAMIC (moves only within the room).
Internally the room boundary must form a convex hull, and by default this is determined automatically by the geometry of the objects you place within the room.
You can alternatively precisely specify a manual bound. If you place a with a name prefixed by Bound_, it will turn off the bound generation from geometry, and instead use the vertices of this MeshInstance to directly calculate a convex hull during the conversion stage (see ).
In order to see from one room into an adjacent room, s must be placed over non-occluded openings between rooms. These will often be placed over doors and windows.
The room hull simplification can either use the default value set in the , or override this and use the per room setting.
The simplify value determines to what degree room hulls (bounds) are simplified, by removing similar planes. A value of 0 gives no simplification, 1 gives maximum simplification.
If points are set, the bounding convex hull will be built from these points. If no points are set, the room bound will either be derived from a manual bound ( with name prefix Bound_), or from the geometry within the room.
Note that you can use the Generate Points editor button to get started. This will use either the geometry or manual bound to generate the room hull, and save the resulting points, allowing you to edit them to further refine the bound.
Sets individual points. Primarily for use by the editor.
Although behavior can be specified individually, sometimes it is faster and more convenient to write functionality for a group of rooms.
s should be placed as children of the room list (the parent of your s), and s should be placed in turn as children of a in order to assign them to the RoomGroup.
A can for example be used to specify s that are outside, and switch on or off a directional light, sky, or rain effect as the player enters / exits the area.
s receive gameplay callbacks when the gameplay_monitor is switched on, as signals or notifications as they enter and exit the gameplay area (see for details).
This priority will be applied to s within the group. The priority allows the use of internal rooms, rooms within another room or rooms.
When the is within more than one room (regular and internal), the higher priority room will take precedence. So with for example, a house inside a terrain 'room', you would make the house higher priority, so that when the camera is within the house, the house is used as the source room, but outside the house, the terrain room would be used instead.
In order to utilize the portal occlusion culling system, you must build your level using s and s. Before these can be used at runtime, they must undergo a short conversion process to build the room graph, runtime data needed for portal culling. The room graph is controlled by the node, and the also contains settings that are common throughout the portal system.
Use only s at runtime to determine visibility. PVS will not be generated at s conversion, and gameplay notifications cannot be used.
Use a combination of PVS and s to determine visibility (this is usually fastest and most accurate).
Use only the PVS (potentially visible set) of s to determine visibility.
Switches the portal culling system on and off.
It is important to note that when portal culling is active, it is responsible for all the 3d culling. Some editor visual debugging helpers may not be available when active, so switching the active flag is intended to be used to ensure your / layout works within the editor.
Switching to active will have no effect when the room graph is unloaded (the rooms have not yet been converted).
Note: For efficiency, the portal system is designed to work with only the core visual object types. In particular, only nodes derived from are expected to show when the system is active.
For the conversion process to succeed, you must point the to the parent of your s and s, which we refer to as the roomlist (the roomlist is not a special node type, it is normally just a ).
Optionally during conversion the potentially visible set (PVS) of rooms that are potentially visible from each room can be calculated. This can be used either to aid in dynamic portal culling, or to totally replace portal culling.
In Full PVS Mode, all objects within the potentially visible rooms will be frustum culled, and rendered if they are within the view frustum.
When using a partial or full PVS, the gameplay monitor allows you to receive callbacks when roaming objects or rooms enter or exit the gameplay area. The gameplay area is defined as either the primary, or secondary PVS.
These callbacks allow you to, for example, reduce processing for objects that are far from the player, or turn on and off AI.
You can either choose to receive callbacks as notifications through the _notification function, or as signals.
NOTIFICATION_ENTER_GAMEPLAY
NOTIFICATION_EXIT_GAMEPLAY
Signals: "gameplay_entered", "gameplay_exited"
When receiving gameplay callbacks when objects enter and exit gameplay, the gameplay area can be defined by either the primary PVS (potentially visible set) of s, or the secondary PVS (the primary PVS and their neighbouring s).
Sometimes using the larger gameplay area of the secondary PVS may be preferable.
If enabled, the system will attempt to merge similar meshes (particularly in terms of materials) within s during conversion. This can significantly reduce the number of drawcalls and state changes required during rendering, albeit at a cost of reduced culling granularity.
Note: This operates at runtime during the conversion process, and will only operate on exported or running projects, in order to prevent accidental alteration to the scene and loss of data.
Shows the margins when the portal gizmo is used in the editor.
Large objects can 'sprawl' over (be present in) more than one room. It can be useful to visualize which objects are sprawling outside the current room.
Toggling this setting turns this debug view on and off.
When converting rooms, the editor will warn you if overlap is detected between rooms. Overlap can interfere with determining the room that cameras and objects are within. A small amount can be acceptable, depending on your level. Here you can alter the threshold at which the editor warning appears. There are no other side effects.
Portal culling normally operates using the current / s, however for debugging purposes within the editor, you can use this setting to override this behavior and force it to use a particular camera to get a better idea of what the occlusion culling is doing.
Portal rendering is recursive - each time a portal is seen through an earlier portal there is some cost. For this reason, and to prevent the possibility of infinite loops, this setting provides a hard limit on the recursion depth.
Note: This value is unused when using Full PVS mode.
During the conversion process, the geometry of objects within s, or a custom specified manual bound, are used to generate a convex hull bound.
This convex hull is required in the visibility system, and is used for many purposes. Most importantly, it is used to decide whether the (or an object) is within a . The convex hull generating algorithm is good, but occasionally it can create too many (or too few) planes to give a good representation of the room volume.
The room_simplify value can be used to gain fine control over this process. It determines how similar planes can be for them to be considered the same (and duplicates removed). The value can be set between 0 (no simplification) and 1 (maximum simplification).
The value set here is the default for all rooms, but individual rooms can override this value if desired.
The room convex hulls are shown as a wireframe in the editor.
Usually we don't want objects that only just cross a boundary into an adjacent to sprawl into that room. To prevent this, each has an extra margin, or tolerance zone where objects can enter without sprawling to a neighbouring room.
In most cases you can set this here for all portals. It is possible to override the margin for each portal.
In order to reduce processing for roaming objects, an expansion is applied to their AABB as they move. This expanded volume is used to calculate which rooms the roaming object is within. If the object's exact AABB is still within this expanded volume on the next move, there is no need to reprocess the object, which can save considerable CPU.
The downside is that if the expansion is too much, the object may end up unexpectedly sprawling into neighbouring rooms and showing up where it might otherwise be culled.
In order to balance roaming performance against culling accuracy, this expansion margin can be customized by the user. It will typically depend on your room and object sizes, and movement speeds. The default value should work reasonably in most circumstances.
This is the most important function in the whole portal culling system. Without it, the system cannot function.
First it goes through every that is a child of the room list node (and s within) and converts and adds it to the room graph.
This works for both nodes, and nodes that follow a special naming convention. They should begin with the prefix 'Room_', followed by the name you wish to give the room, e.g. 'Room_lounge'. This will automatically convert such s to nodes for you. This is useful if you want to build you entire room system in e.g. Blender, and reimport multiple times as you work on the level.
The conversion will try to assign s that are children and grandchildren of the to the room. These should be given a suitable portal mode (see the documentation). The default portal mode is STATIC - objects which are not expected to move while the level is played, which will typically be most objects.
The conversion will usually use the geometry of these s (and the s) to calculate a convex hull bound for the room. These bounds will be shown in the editor with a wireframe. Alternatively you can specify a manual custom bound for any room, see the documentation.
By definition, s within a room can see everything else within the room (that is one advantage to using convex hulls). However, in order to see from one room into adjacent rooms, you must place s, which represent openings that the camera can see through, like windows and doors.
s are really just specialized s. In fact you will usually first create a portal by creating a , especially a plane mesh instance. You would move the plane in the editor to cover a window or doorway, with the front face pointing outward from the room. To let the conversion process know you want this mesh to be a portal, again we use a special naming convention. s to be converted to a should start with the prefix 'Portal_'.
You now have a choice - you can leave the name as 'Portal_' and allow the system to automatically detect the nearest to link. In most cases this will work fine.
An alternative method is to specify the to link to manually, appending a suffix to the portal name, which should be the name of the room you intend to link to. For example 'Portal_lounge' will attempt to link to the room named 'Room_lounge'.
There is a special case here - Godot does not allow two nodes to share the same name. What if you want to manually have more than one portal leading into the same room? Surely they will need to both be called, e.g. 'Portal_lounge'?
The solution is a wildcard character. After the room name, if you use the character '*', this character and anything following it will be ignored. So you can use for example 'Portal_lounge*0', 'Portal_lounge*1' etc.
Note that s that have already been converted to nodes (rather than s) still need to follow the same naming convention, as they will be relinked each time during conversion.
It is recommended that you only place objects in rooms that are desired to stay within those rooms - i.e. portal modes STATIC or DYNAMIC (not crossing portals). GLOBAL and ROAMING objects are best placed in another part of the scene tree, to avoid confusion. See for a full description of portal modes.
This function clears all converted data from the room graph. Use this before unloading a level, when transitioning from level to level, or returning to a main menu.
Maintains a list of resources, nodes, exported, and overridden properties, and built-in scripts associated with a scene.
This class cannot be instantiated directly, it is retrieved for a given scene as the result of .
If passed to , blocks edits to the scene state.
If passed to , provides inherited scene resources to the local scene.
Note: Only available in editor builds.
If passed to , provides local scene resources to the local scene. Only the main scene should receive the main edit state.
Note: Only available in editor builds.
If passed to , it's similar to , but for the case where the scene is being instantiated to be the base of another one.
Note: Only available in editor builds.
Returns the number of nodes in the scene.
The idx argument used to query node data in other get_node_* methods in the interval [0, get_node_count() - 1].
Returns the type of the node at idx.
Returns the name of the node at idx.
Returns the path to the node at idx.
If for_parent is true, returns the path of the idx node's parent instead.
Returns the path to the owner of the node at idx, relative to the root node.
Returns true if the node at idx is an .
Returns the path to the represented scene file if the node at idx is an .
Returns a for the node at idx (i.e. the whole branch starting at this node, with its child nodes and resources), or null if the node is not an instance.
Returns the list of group names associated with the node at idx.
Returns the node's index, which is its position relative to its siblings. This is only relevant and saved in scenes for cases where new nodes are added to an instanced or inherited scene among siblings from the base scene. Despite the name, this index is not related to the idx argument used here and in other methods.
Returns the number of exported or overridden properties for the node at idx.
The prop_idx argument used to query node property data in other get_node_property_* methods in the interval [0, get_node_property_count() - 1].
Returns the name of the property at prop_idx for the node at idx.
Returns the value of the property at prop_idx for the node at idx.
Returns the number of signal connections in the scene.
The idx argument used to query connection metadata in other get_connection_* methods in the interval [0, get_connection_count() - 1].
Returns the path to the node that owns the signal at idx, relative to the root node.
Returns the name of the signal at idx.
Returns the path to the node that owns the method connected to the signal at idx, relative to the root node.
Returns the method connected to the signal at idx.
Returns the connection flags for the signal at idx. See constants.
Returns the list of bound parameters for the signal at idx.
As one of the most important classes, the manages the hierarchy of nodes in a scene as well as scenes themselves. Nodes can be added, retrieved and removed. The whole scene tree (and thus the current scene) can be paused. Scenes can be loaded, switched and reloaded.
You can also use the to organize your nodes into groups: every node can be assigned as many groups as you want to create, e.g. an "enemy" group. You can then iterate these groups or even call methods and set properties on all the group's members at once.
is the default implementation used by scenes, and is thus in charge of the game loop.
Fill the window with the content stretched to cover excessive space. Content may appear stretched.
Retain the same aspect ratio by padding with black bars on either axis. This prevents distortion.
Expand vertically. Left/right black bars may appear if the window is too wide.
Expand horizontally. Top/bottom black bars may appear if the window is too tall.
Expand in both directions, retaining the same aspect ratio. This prevents distortion while avoiding black bars.
Call a group with no flags (default).
Call a group in reverse scene order.
Call a group immediately (calls are normally made on idle).
Call a group only once even if the call is executed many times.
No stretching.
Render stretching in higher resolution (interpolated).
Keep the specified display resolution. No interpolation. Content may appear pixelated.
If true, the application automatically accepts quitting.
For mobile platforms, see .
If true, the application quits automatically on going back (e.g. on Android).
To handle 'Go Back' button when this option is disabled, use .
If true, collision shapes will be visible when running the game from the editor for debugging purposes.
Note: This property is not designed to be changed at run-time. Changing the value of while the project is running will not have the desired effect.
If true, navigation polygons will be visible when running the game from the editor for debugging purposes.
Note: This property is not designed to be changed at run-time. Changing the value of while the project is running will not have the desired effect.
If true, the is paused. Doing so will have the following behavior:
- 2D and 3D physics will be stopped. This includes signals and collision detection.
- , and will not be called anymore in nodes.
If true, the 's refuses new incoming connections.
If true, font oversampling is enabled. This means that s will be rendered at higher or lower size than configured based on the viewport's scaling ratio. For example, in a viewport scaled with a factor 1.5, a font configured with size 14 would be rendered with size 21 (14 * 1.5).
Note: Font oversampling is only used if the viewport stretch mode is , and if the stretch aspect mode is different from .
Note: This property is set automatically for the active when the project starts based on the configuration of rendering/quality/dynamic_fonts/use_oversampling in . The property can however be overridden at runtime as needed.
The root of the edited scene.
The current scene.
The peer object to handle the RPC system (effectively enabling networking when set). Depending on the peer itself, the will become a network server (check with ) and will set the root node's network mode to master, or it will become a regular peer with the root node set to puppet. All child nodes are set to inherit the network mode by default. Handling of networking-related events (connection, disconnection, new clients) is done by connecting to 's signals.
The 's root .
The default instance for this .
If true (default value), enables automatic polling of the for this SceneTree during idle_frame.
If false, you need to manually call to process network packets and deliver RPCs/RSETs. This allows running RPCs/RSETs in a different loop (e.g. physics, thread, specific time step) and for manual protection when accessing the from threads.
Although physics interpolation would normally be globally turned on and off using , this property allows control over interpolation at runtime.
Returns true if the given group exists.
Marks the most recent as handled.
Returns true if the most recent was marked as handled with .
Returns a which will SceneTreeTimer.timeout after the given time in seconds elapsed in this . If pause_mode_process is set to false, pausing the will also pause the timer.
Commonly used to create a one-shot delay timer as in the following example:
func some_function():
print("start")
yield(get_tree().create_timer(1.0), "timeout")
print("end")
The timer will be automatically freed after its time elapses.
Creates and returns a new .
Returns an array of currently existing s in the (both running and paused).
Returns the number of nodes in this .
Returns the current frame number, i.e. the total frame count since the application started.
Quits the application at the end of the current iteration. A process exit_code can optionally be passed as an argument. If this argument is 0 or greater, it will override the defined before quitting the application.
Note: On iOS this method doesn't work. Instead, as recommended by the iOS Human Interface Guidelines, the user is expected to close apps via the Home button.
Configures screen stretching to the given , , minimum size and scale.
Queues the given object for deletion, delaying the call to to after the current frame.
Calls method on each member of the given group, respecting the given . You can pass arguments to method by specifying them at the end of the method call.
Note: method may only have 5 arguments at most (8 arguments passed to this method in total).
Note: Due to design limitations, will fail silently if one of the arguments is null.
# Call the method immediately and in reverse order.
get_tree().call_group_flags(SceneTree.GROUP_CALL_REALTIME | SceneTree.GROUP_CALL_REVERSE, "bases", "destroy")
Sends the given notification to all members of the group, respecting the given .
Sets the given property to value on all members of the given group, respecting the given .
Calls method on each member of the given group. You can pass arguments to method by specifying them at the end of the method call. This method is equivalent of calling with flag.
Note: method may only have 5 arguments at most (7 arguments passed to this method in total).
Note: Due to design limitations, will fail silently if one of the arguments is null.
Note: will always call methods with an one-frame delay, in a way similar to . To call methods immediately, use with the flag.
Sends the given notification to all members of the group.
Sets the given property to value on all members of the given group.
Returns a list of all nodes assigned to the given group.
Changes the running scene to the one at the given path, after loading it into a and creating a new instance.
Returns OK on success, ERR_CANT_OPEN if the path cannot be loaded into a , or ERR_CANT_CREATE if that scene cannot be instantiated.
Note: The scene change is deferred, which means that the new scene node is added on the next idle frame. You won't be able to access it immediately after the call.
Changes the running scene to a new instance of the given .
Returns OK on success or ERR_CANT_CREATE if the scene cannot be instantiated.
Note: The scene change is deferred, which means that the new scene node is added on the next idle frame. You won't be able to access it immediately after the call.
Note: Passing a value of null into the method will unload the current scene without loading a new one.
Reloads the currently active scene.
Returns OK on success, ERR_UNCONFIGURED if no was defined yet, ERR_CANT_OPEN if cannot be loaded into a , or ERR_CANT_CREATE if the scene cannot be instantiated.
Returns true if this 's is in server mode (listening for connections).
Returns true if there is a set.
Returns the peer IDs of all connected peers of this 's .
Returns the unique peer ID of this 's .
Returns the sender's peer ID for the most recently received RPC call.
A one-shot timer managed by the scene tree, which emits timeout on completion. See also .
As opposed to , it does not require the instantiation of a node. Commonly used to create a one-shot delay timer as in the following example:
func some_function():
print("Timer started.")
yield(get_tree().create_timer(1.0), "timeout")
print("Timer ended.")
The timer will be dereferenced after its time elapses. To preserve the timer, you can keep a reference to it. See .
The time remaining (in seconds).
is a tween managed by the scene tree. As opposed to , it does not require the instantiation of a node.
s are more light-weight than , so they are very much suited for simple animations or general tasks that don't require visual tweaking provided by the editor. They can be used in a fire-and-forget manner for some logic that normally would be done by code. You can e.g. make something shoot periodically by using a looped with a delay.
A can be created by using either or . s created manually (i.e. by using Tween.new()) are invalid. They can't be used for tweening values, but you can do manual interpolation with .
A tween animation is created by adding s to the object, using , , or :
var tween = get_tree().create_tween()
tween.tween_property($Sprite, "modulate", Color.red, 1)
tween.tween_property($Sprite, "scale", Vector2(), 1)
tween.tween_callback($Sprite, "queue_free")
This sequence will make the $Sprite node turn red, then shrink, before finally calling to free the sprite. s are executed one after another by default. This behavior can be changed using and .
When a is created with one of the tween_* methods, a chained method call can be used to tweak the properties of this . For example, if you want to set a different transition type in the above example, you can use :
var tween = get_tree().create_tween()
tween.tween_property($Sprite, "modulate", Color.red, 1).set_trans(Tween.TRANS_SINE)
tween.tween_property($Sprite, "scale", Vector2(), 1).set_trans(Tween.TRANS_BOUNCE)
tween.tween_callback($Sprite, "queue_free")
Most of the methods can be chained this way too. In the following example the is bound to the running script's node and a default transition is set for its s:
var tween = get_tree().create_tween().bind_node(self).set_trans(Tween.TRANS_ELASTIC)
tween.tween_property($Sprite, "modulate", Color.red, 1)
tween.tween_property($Sprite, "scale", Vector2(), 1)
tween.tween_callback($Sprite, "queue_free")
Another interesting use for s is animating arbitrary sets of objects:
var tween = create_tween()
for sprite in get_children():
tween.tween_property(sprite, "position", Vector2(0, 0), 1)
In the example above, all children of a node are moved one after another to position (0, 0).
You should avoid using more than one per object's property. If two or more tweens animate one property at the same time, the last one created will take priority and assign the final value. If you want to interrupt and restart an animation, consider assigning the to a variable:
var tween
func animate():
if tween:
tween.kill() # Abort the previous animation.
tween = create_tween()
Some s use transitions and eases. The first accepts a constant, and refers to the way the timing of the animation is handled (see easings.net for some examples). The second accepts an constant, and controls where the trans_type is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different constants with , and use the one that looks best.
Tween easing and transition types cheatsheet
Note: All s will automatically start by default. To prevent a from autostarting, you can call immediately after it is created.
Note: s are processing after all of nodes in the current frame, i.e. after or (depending on ).
If the has a bound node, it will process when that node can process (see ). Otherwise it's the same as .
If is paused, the will also pause.
The will process regardless of whether is paused.
Creates and appends a . This method tweens a property of an object between an initial value and final_val in a span of time equal to duration, in seconds. The initial value by default is the property's value at the time the tweening of the starts. For example:
var tween = create_tween()
tween.tween_property($Sprite, "position", Vector2(100, 200), 1)
tween.tween_property($Sprite, "position", Vector2(200, 300), 1)
will move the sprite to position (100, 200) and then to (200, 300). If you use or , the starting position will be overwritten by the given value instead. See other methods in to see how the tweening can be tweaked further.
Note: You can find the correct property name by hovering over the property in the Inspector. You can also provide the components of a property directly by using "property:component" (eg. position:x), where it would only apply to that particular component.
Example: moving object twice from the same position, with different transition types.
var tween = create_tween()
tween.tween_property($Sprite, "position", Vector2.RIGHT * 300, 1).as_relative().set_trans(Tween.TRANS_SINE)
tween.tween_property($Sprite, "position", Vector2.RIGHT * 300, 1).as_relative().from_current().set_trans(Tween.TRANS_EXPO)
Creates and appends an . This method can be used to create delays in the tween animation, as an alternative to using the delay in other s, or when there's no animation (in which case the acts as a timer). time is the length of the interval, in seconds.
Example: creating an interval in code execution.
# ... some code
yield(create_tween().tween_interval(2), "finished")
# ... more code
Example: creating an object that moves back and forth and jumps every few seconds.
var tween = create_tween().set_loops()
tween.tween_property($Sprite, "position:x", 200.0, 1).as_relative()
tween.tween_callback(self, "jump")
tween.tween_interval(2)
tween.tween_property($Sprite, "position:x", -200.0, 1).as_relative()
tween.tween_callback(self, "jump")
tween.tween_interval(2)
Creates and appends a . This method can be used to call an arbitrary method in any object. Use binds to bind additional arguments for the call.
Example: object that keeps shooting every 1 second.
var tween = get_tree().create_tween().set_loops()
tween.tween_callback(self, "shoot").set_delay(1)
Example: turning a sprite red and then blue, with 2 second delay.
var tween = get_tree().create_tween()
tween.tween_callback($Sprite, "set_modulate", [Color.red]).set_delay(2)
tween.tween_callback($Sprite, "set_modulate", [Color.blue]).set_delay(2)
If the parameter is null, then the default value is new Godot.Collections.Array { }
Creates and appends a . This method is similar to a combination of and . It calls a method over time with a tweened value provided as an argument. The value is tweened between from and to over the time specified by duration, in seconds. Use binds to bind additional arguments for the call. You can use and to tweak the easing and transition of the value or to delay the tweening.
Example: making a 3D object look from one point to another point.
var tween = create_tween()
tween.tween_method(self, "look_at", Vector3(-1, 0, -1), Vector3(1, 0, -1), 1, [Vector3.UP]) # The look_at() method takes up vector as second argument.
Example: setting a text of a , using an intermediate method and after a delay.
func _ready():
var tween = create_tween()
tween.tween_method(self, "set_label_text", 0, 10, 1).set_delay(1)
func set_label_text(value: int):
$Label.text = "Counting " + str(value)
If the parameter is null, then the default value is new Godot.Collections.Array { }
Processes the by the given delta value, in seconds. This is mostly useful for manual control when the is paused. It can also be used to end the animation immediately, by setting delta longer than the whole duration of the animation.
Returns true if the still has s that haven't finished.
Note: The will become invalid in the next processing frame after its animation finishes. Calling after performing instead keeps and resets the .
Stops the tweening and resets the to its initial state. This will not remove any appended s.
Pauses the tweening. The animation can be resumed by using .
Resumes a paused or stopped .
Aborts all tweening operations and invalidates the .
Returns the total time in seconds the has been animating (i.e. the time since it started, not counting pauses etc.). The time is affected by , and will reset it to 0.
Note: As it results from accumulating frame deltas, the time returned after the has finished animating will be slightly greater than the actual duration.
Returns whether the is currently running, i.e. it wasn't paused and it's not finished.
Returns whether the is valid. A valid is a contained by the scene tree (i.e. the array from will contain this ). A might become invalid when it has finished tweening, is killed, or when created with SceneTreeTween.new(). Invalid s can't have s appended. You can however still use .
Binds this with the given node. s are processed directly by the , so they run independently of the animated nodes. When you bind a with the , the will halt the animation when the object is not inside tree and the will be automatically killed when the bound object is freed. Also will make the pausing behavior dependent on the bound node.
For a shorter way to create and bind a , you can use .
Determines whether the should run during idle frame (see ) or physics frame (see .
Default value is .
Determines the behavior of the when the is paused. Check for options.
Default value is .
If parallel is true, the s appended after this method will by default run simultaneously, as opposed to sequentially.
Sets the number of times the tweening sequence will be repeated, i.e. set_loops(2) will run the animation twice.
Calling this method without arguments will make the run infinitely, until either it is killed with , the 's bound node is freed, or all the animated objects have been freed (which makes further animation impossible).
Warning: Make sure to always add some duration/delay when using infinite loops. To prevent the game freezing, 0-duration looped animations (e.g. a single with no delay) are stopped after a small number of loops, which may produce unexpected results. If a 's lifetime depends on some node, always use .
Scales the speed of tweening. This affects all s and their delays.
Sets the default transition type for s and s animated by this .
Sets the default ease type for s and s animated by this .
Makes the next run parallelly to the previous one. Example:
var tween = create_tween()
tween.tween_property(...)
tween.parallel().tween_property(...)
tween.parallel().tween_property(...)
All s in the example will run at the same time.
You can make the parallel by default by using .
Used to chain two s after is called with true.
var tween = create_tween().set_parallel(true)
tween.tween_property(...)
tween.tween_property(...) # Will run parallelly with above.
tween.chain().tween_property(...) # Will run after two above are finished.
This method can be used for manual interpolation of a value, when you don't want to do animating for you. It's similar to @GDScript.lerp, but with support for custom transition and easing.
initial_value is the starting value of the interpolation.
delta_value is the change of the value in the interpolation, i.e. it's equal to final_value - initial_value.
elapsed_time is the time in seconds that passed after the interpolation started and it's used to control the position of the interpolation. E.g. when it's equal to half of the duration, the interpolated value will be halfway between initial and final values. This value can also be greater than duration or lower than 0, which will extrapolate the value.
duration is the total time of the interpolation.
Note: If duration is equal to 0, the method will always return the final value, regardless of elapsed_time provided.
A class stored as a resource. A script extends the functionality of all objects that instance it.
The new method of a script subclass creates a new instance. extends an existing object, if that object's class matches one of the script's base classes.
The script source code or an empty string if source code is not available. When set, does not reload the class implementation automatically.
Returns true if the script can be instanced.
Returns true if base_object is an instance of this script.
Returns true if the script contains non-empty source code.
Reloads the script's class implementation. Returns an error code.
Returns the script directly inherited by this script.
Returns the script's base type.
Returns true if the script, or a base class, defines a signal with the given name.
Returns the list of properties in this .
Returns the list of methods in this .
Returns the list of user signals defined in this .
Returns a dictionary containing constant names and their values.
Returns the default value of the specified property.
Returns true if the script is a tool script. A tool script can run in the editor.
Scrollbars are a -based , that display a draggable area (the size of the page). Horizontal () and Vertical () versions are available.
Overrides the step used when clicking increment and decrement buttons or when using arrow keys when the is focused.
A ScrollContainer node meant to contain a child. ScrollContainers will automatically create a scrollbar child (, , or both) when needed and will only draw the Control within the ScrollContainer area. Scrollbars will automatically be drawn at the right (for vertical) or bottom (for horizontal) and will enable dragging to move the viewable Control (and its children) within the ScrollContainer. Scrollbars will also automatically resize the grabber based on the of the Control relative to the ScrollContainer. Works great with a control. You can set EXPAND on the children's size flags, so they will upscale to the ScrollContainer's size if it's larger (scroll is invisible for the chosen dimension).
If true, the ScrollContainer will automatically scroll to focused children (including indirect children) to make sure they are fully visible.
If true, enables horizontal scrolling.
The current horizontal scroll value.
If true, enables vertical scrolling.
The current vertical scroll value.
Returns the horizontal scrollbar of this .
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to disable the horizontal scrollbar, use . If you want to only hide it instead, use its property.
Returns the vertical scrollbar of this .
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to disable the vertical scrollbar, use . If you want to only hide it instead, use its property.
Ensures the given control is visible (must be a direct or indirect child of the ScrollContainer). Used by .
Note: This will not work on a node that was just added during the same frame. If you want to scroll to a newly added child, you must wait until the next frame using SceneTree.idle_frame:
add_child(child_node)
yield(get_tree(), "idle_frame")
ensure_control_visible(child_node)
Segment shape for 2D collisions. Consists of two points, a and b.
The segment's first point position.
The segment's second point position.
Separator is a used for separating other controls. It's purely a visual decoration. Horizontal () and Vertical () versions are available.
This class allows you to define a custom shader program that can be used by a . Shaders allow you to write your own custom behavior for rendering objects or updating particle information. For a detailed explanation and usage, please see the tutorials linked below.
Mode used to draw all 3D objects.
Mode used to draw all 2D objects.
Mode used to calculate particle information on a per-particle basis. Not used for drawing.
Returns the shader's code as the user has written it, not the full generated code used internally.
Returns the shader's custom defines. Custom defines can be used in Godot to add GLSL preprocessor directives (e.g: extensions) required for the shader logic.
Note: Custom defines are not validated by the Godot shader parser, so care should be taken when using them.
Returns the shader mode for the shader, either , or .
Sets the default texture to be used with a texture uniform. The default is used if a texture is not set in the .
Note: param must match the name of the uniform in the code exactly.
Returns the texture that is set as default for the specified parameter.
Note: param must match the name of the uniform in the code exactly.
Returns true if the shader has this param defined as a uniform in its code.
Note: param must match the name of the uniform in the code exactly.
A material that uses a custom program to render either items to screen or process particles. You can create multiple materials for the same shader but configure different values for the uniforms defined in the shader.
Note: Due to a renderer limitation, emissive s cannot emit light when used in a . Only emissive s can emit light in a .
The program used to render this material.
Changes the value set for this material of a uniform in the shader.
Note: param must match the name of the uniform in the code exactly.
Returns the current value set for this material of a uniform in the shader.
Returns true if the property identified by name can be reverted to a default value.
Returns the default value of the material property with given name.
Base class for all 3D shape resources. Nodes that inherit from this can be used as shapes for a or objects.
The collision margin for the shape. Used in Bullet Physics only.
Collision margins allow collision detection to be more efficient by adding an extra shell around shapes. Collision algorithms are more expensive when objects overlap by more than their margin, so a higher value for margins is better for performance, at the cost of accuracy around edges as it makes them less sharp.
Returns the used to draw the debug collision for this .
Base class for all 2D shapes. All 2D shape types inherit from this.
The shape's custom solver bias. Defines how much bodies react to enforce contact separation when this shape is involved.
When set to 0.0, the default value of 0.3 is used.
Returns true if this shape is colliding with another.
This method needs the transformation matrix for this shape (local_xform), the shape to check collisions with (with_shape), and the transformation matrix of that shape (shape_xform).
Returns whether this shape would collide with another, if a given movement was applied.
This method needs the transformation matrix for this shape (local_xform), the movement to test on this shape (local_motion), the shape to check collisions with (with_shape), the transformation matrix of that shape (shape_xform), and the movement to test onto the other object (shape_motion).
Returns a list of contact point pairs where this shape touches another.
If there are no collisions, the returned list is empty. Otherwise, the returned list contains contact points arranged in pairs, with entries alternating between points on the boundary of this shape and points on the boundary of with_shape.
A collision pair A, B can be used to calculate the collision normal with (B - A).normalized(), and the collision depth with (B - A).length(). This information is typically used to separate shapes, particularly in collision solvers.
This method needs the transformation matrix for this shape (local_xform), the shape to check collisions with (with_shape), and the transformation matrix of that shape (shape_xform).
Returns a list of contact point pairs where this shape would touch another, if a given movement was applied.
If there would be no collisions, the returned list is empty. Otherwise, the returned list contains contact points arranged in pairs, with entries alternating between points on the boundary of this shape and points on the boundary of with_shape.
A collision pair A, B can be used to calculate the collision normal with (B - A).normalized(), and the collision depth with (B - A).length(). This information is typically used to separate shapes, particularly in collision solvers.
This method needs the transformation matrix for this shape (local_xform), the movement to test on this shape (local_motion), the shape to check collisions with (with_shape), the transformation matrix of that shape (shape_xform), and the movement to test onto the other object (shape_motion).
Draws a solid shape onto a with the API filled with the specified color. The exact drawing method is specific for each shape and cannot be configured.
A shortcut for binding input.
Shortcuts are commonly used for interacting with a element from a .
The shortcut's .
Generally the is a keyboard key, though it can be any .
If true, this shortcut is valid.
Returns true if the shortcut's equals event.
Returns the shortcut's as a .
Skeleton provides a hierarchical interface for managing bones, including pose, rest and animation (see ). It can also use ragdoll physics.
The overall transform of a bone with respect to the skeleton is determined by the following hierarchical order: rest pose, custom pose and pose.
Note that "global pose" below refers to the overall transform of the bone with respect to skeleton, so it not the actual global/world transform of the bone.
Adds a bone, with name name. will become the bone index.
Returns the bone index that matches name as its name.
Returns the name of the bone at index index.
Returns the bone index which is the parent of the bone at bone_idx. If -1, then bone has no parent.
Note: The parent bone returned will always be less than bone_idx.
Sets the bone index parent_idx as the parent of the bone at bone_idx. If -1, then bone has no parent.
Note: parent_idx must be less than bone_idx.
Returns the amount of bones in the skeleton.
Returns the rest transform for a bone bone_idx.
Sets the rest transform for bone bone_idx.
Deprecated soon.
Deprecated soon.
Deprecated soon.
Clear all the bones in this skeleton.
Returns the pose transform of the specified bone. Pose is applied on top of the custom pose, which is applied on top the rest pose.
Sets the pose transform for bone bone_idx.
Returns the overall transform of the specified bone, with respect to the skeleton. Being relative to the skeleton frame, this is not the actual "global" transform of the bone.
Returns the overall transform of the specified bone, with respect to the skeleton, but without any global pose overrides. Being relative to the skeleton frame, this is not the actual "global" transform of the bone.
Returns the custom pose of the specified bone. Custom pose is applied on top of the rest pose.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Skeleton2D parents a hierarchy of objects. It is a requirement of . Skeleton2D holds a reference to the rest pose of its children and acts as a single point of access to its bones.
Returns the number of nodes in the node hierarchy parented by Skeleton2D.
Returns a from the node hierarchy parented by Skeleton2D. The object to return is identified by the parameter idx. Bones are indexed by descending the node hierarchy from top to bottom, adding the children of each branch before moving to the next sibling.
Returns the of a Skeleton2D instance.
SkeletonIK is used to place the end bone of a bone chain at a certain point in 3D by rotating all bones in the chain accordingly. A typical scenario for IK in games is to place a characters feet on the ground or a characters hands on a currently hold object. SkeletonIK uses FabrikInverseKinematic internally to solve the bone chain and applies the results to the bones_global_pose_override property for all affected bones in the chain. If fully applied this overwrites any bone transform from s or bone custom poses set by users. The applied amount can be controlled with the interpolation property.
# Apply IK effect automatically on every new frame (not the current)
skeleton_ik_node.start()
# Apply IK effect only on the current frame
skeleton_ik_node.start(true)
# Stop IK effect and reset bones_global_pose_override on Skeleton
skeleton_ik_node.stop()
# Apply full IK effect
skeleton_ik_node.set_interpolation(1.0)
# Apply half IK effect
skeleton_ik_node.set_interpolation(0.5)
# Apply zero IK effect (a value at or below 0.01 also removes bones_global_pose_override on Skeleton)
skeleton_ik_node.set_interpolation(0.0)
The name of the current root bone, the first bone in the IK chain.
The name of the current tip bone, the last bone in the IK chain placed at the transform (or if defined).
Interpolation value for how much the IK results are applied to the current skeleton bone chain. A value of 1.0 will overwrite all skeleton bone transforms completely while a value of 0.0 will visually disable the SkeletonIK. A value at or below 0.01 also calls .
First target of the IK chain where the tip bone is placed and, if is true, how the tip bone is rotated. If a path is available the nodes transform is used instead and this property is ignored.
If true overwrites the rotation of the tip bone with the rotation of the (or if defined).
If true, instructs the IK solver to consider the secondary magnet target (pole target) when calculating the bone chain. Use the magnet position (pole target) to control the bending of the IK chain.
Secondary target position (first is property or ) for the IK chain. Use magnet position (pole target) to control the bending of the IK chain. Only works if the bone chain has more than 2 bones. The middle chain bone position will be linearly interpolated with the magnet position.
Target node for the IK chain. If available, the node's current is used instead of the property.
The minimum distance between bone and goal target. If the distance is below this value, the IK solver stops further iterations.
Number of iteration loops used by the IK solver to produce more accurate (and elegant) bone chain results.
Returns the parent Node that was present when SkeletonIK entered the . Returns null if the parent node was not a Node when SkeletonIK entered the .
Returns true if SkeletonIK is applying IK effects on continues frames to the bones. Returns false if SkeletonIK is stopped or was used with the one_time parameter set to true.
Starts applying IK effects on each frame to the bones but will only take effect starting on the next frame. If one_time is true, this will take effect immediately but also reset on the next frame.
Stops applying IK effects on each frame to the bones and also calls to remove existing overrides on all bones.
The base class for and .
Radiance texture size is 32×32 pixels.
Radiance texture size is 64×64 pixels.
Radiance texture size is 128×128 pixels.
Radiance texture size is 256×256 pixels.
Radiance texture size is 512×512 pixels.
Radiance texture size is 1024×1024 pixels.
Note: is not exposed in the inspector as it is known to cause GPU hangs on certain systems.
Radiance texture size is 2048×2048 pixels.
Note: is not exposed in the inspector as it is known to cause GPU hangs on certain systems.
Represents the size of the enum.
The 's radiance map size. The higher the radiance map size, the more detailed the lighting from the will be.
See constants for values.
Note: You will only benefit from high radiance sizes if you have perfectly sharp reflective surfaces in your project and are not using s or s. For most projects, keeping to the default value is the best compromise between visuals and performance. Be careful when using high radiance size values as these can cause crashes on low-end GPUs.
Base class for GUI sliders.
Note: The Range.changed and Range.value_changed signals are part of the class which this class inherits from.
If true, the slider can be interacted with. If false, the value can be changed only by code.
If true, the value can be changed using the mouse wheel.
Number of ticks displayed on the slider, including border ticks. Ticks are uniformly-distributed value markers.
If true, the slider will display ticks for minimum and maximum values.
Slides across the X axis of the pivot object. See also .
The maximum difference between the pivot points on their X axis before damping happens.
The minimum difference between the pivot points on their X axis before damping happens.
A factor applied to the movement across the slider axis once the limits get surpassed. The lower, the slower the movement.
The amount of restitution once the limits are surpassed. The lower, the more velocityenergy gets lost.
The amount of damping once the slider limits are surpassed.
A factor applied to the movement across the slider axis as long as the slider is in the limits. The lower, the slower the movement.
The amount of restitution inside the slider limits.
The amount of damping inside the slider limits.
A factor applied to the movement across axes orthogonal to the slider.
The amount of restitution when movement is across axes orthogonal to the slider.
The amount of damping when movement is across axes orthogonal to the slider.
The upper limit of rotation in the slider.
The lower limit of rotation in the slider.
A factor applied to the all rotation once the limit is surpassed.
The amount of restitution of the rotation when the limit is surpassed.
The amount of damping of the rotation when the limit is surpassed.
A factor applied to the all rotation in the limits.
The amount of restitution of the rotation in the limits.
The amount of damping of the rotation in the limits.
A factor applied to the all rotation across axes orthogonal to the slider.
The amount of restitution of the rotation across axes orthogonal to the slider.
The amount of damping of the rotation across axes orthogonal to the slider.
Represents the size of the enum.
The maximum difference between the pivot points on their X axis before damping happens.
The minimum difference between the pivot points on their X axis before damping happens.
A factor applied to the movement across the slider axis once the limits get surpassed. The lower, the slower the movement.
The amount of restitution once the limits are surpassed. The lower, the more velocity-energy gets lost.
The amount of damping that happens once the limit defined by and is surpassed.
A factor applied to the movement across the slider axis as long as the slider is in the limits. The lower, the slower the movement.
The amount of restitution inside the slider limits.
The amount of damping inside the slider limits.
A factor applied to the movement across axes orthogonal to the slider.
The amount of restitution when movement is across axes orthogonal to the slider.
The amount of damping when movement is across axes orthogonal to the slider.
The upper limit of rotation in the slider.
The lower limit of rotation in the slider.
A factor applied to the all rotation once the limit is surpassed.
Makes all rotation slower when between 0 and 1.
The amount of restitution of the rotation when the limit is surpassed.
Does not affect damping.
The amount of damping of the rotation when the limit is surpassed.
A lower damping value allows a rotation initiated by body A to travel to body B slower.
A factor applied to the all rotation in the limits.
The amount of restitution of the rotation in the limits.
The amount of damping of the rotation in the limits.
A factor applied to the all rotation across axes orthogonal to the slider.
The amount of restitution of the rotation across axes orthogonal to the slider.
The amount of damping of the rotation across axes orthogonal to the slider.
A deformable physics body. Used to create elastic or deformable objects such as cloth, rubber, or other flexible materials.
Note: There are many known bugs in . Therefore, it's not recommended to use them for things that can affect gameplay (such as a player character made entirely out of soft bodies).
If true, the is simulated in physics. Can be set to false to pause the physics simulation.
The physics layers this SoftBody is in.
Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See Collision layers and masks in the documentation for more information.
The physics layers this SoftBody scans for collisions. See Collision layers and masks in the documentation for more information.
to a this SoftBody should avoid clipping.
Increasing this value will improve the resulting simulation, but can affect performance. Use with care.
The SoftBody's mass.
If true, the will respond to s.
Sets individual bits on the collision mask. Use this if you only need to change one layer's value.
Returns an individual bit on the collision mask.
Sets individual bits on the layer mask. Use this if you only need to change one layer's value.
Returns an individual bit on the collision mask.
Returns an array of nodes that were added as collision exceptions for this body.
Adds a body to the list of bodies that this body can't collide with.
Removes a body from the list of bodies that this body can't collide with.
Returns local translation of a vertex in the surface array.
Sets the pinned state of a surface vertex. When set to true, the optional attachment_path can define a the pinned vertex will be attached to.
If the parameter is null, then the default value is (NodePath)""
Returns true if vertex is set to pinned.
Most basic 3D game object, with a 3D and visibility settings. All other 3D game objects inherit from Spatial. Use as a parent node to move, scale, rotate and show/hide children in a 3D project.
Affine operations (rotate, scale, translate) happen in parent's local coordinate system, unless the object is set as top-level. Affine operations in this coordinate system correspond to direct affine operations on the 's transform. The word local below refers to this coordinate system. The coordinate system that is attached to the object itself is referred to as object-local coordinate system.
Note: Unless otherwise specified, all methods that have angle parameters must have angles specified as radians. To convert degrees to radians, use @GDScript.deg2rad.
Spatial nodes receives this notification when their global transform changes. This means that either the current or a parent node changed its transform.
In order for to work, users first need to ask for it, with . The notification is also sent if the node is in the editor context and it has a valid gizmo.
Spatial nodes receives this notification when they are registered to new resource.
Spatial nodes receives this notification when they are unregistered from current resource.
Spatial nodes receives this notification when their visibility changes.
Spatial nodes receives this notification if the portal system gameplay monitor detects they have entered the gameplay area.
Spatial nodes receives this notification if the portal system gameplay monitor detects they have exited the gameplay area.
Local translation of this node.
Rotation part of the local transformation in degrees, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
Rotation part of the local transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
Note: In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a data structure not because the rotation is a vector, but only because exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.
Scale part of the local transformation.
Note: Mixed negative scales in 3D are not decomposable from the transformation matrix. Due to the way scale is represented with transformation matrices in Godot, the scale values will either be all positive or all negative.
World space (global) of this node.
Global position of this node. This is equivalent to global_transform.origin.
Rotation part of the global transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
Note: In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a data structure not because the rotation is a vector, but only because exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.
Local space of this node, with respect to the parent node.
If true, this node is drawn. The node is only visible if all of its antecedents are visible as well (in other words, must return true).
The for this node. Used for example in as custom visualization and editing handles in Editor.
When using physics interpolation, there will be circumstances in which you want to know the interpolated (displayed) transform of a node rather than the standard transform (which may only be accurate to the most recent physics tick).
This is particularly important for frame-based operations that take place in , rather than . Examples include s focusing on a node, or finding where to fire lasers from on a frame rather than physics tick.
Returns the parent , or an empty if no parent exists or parent is not of type .
Sets whether the node ignores notification that its transformation (global or local) changed.
Makes the node ignore its parents transformations. Node transformations are only in global space.
Returns whether this node is set as Toplevel, that is whether it ignores its parent nodes transformations.
Sets whether the node uses a scale of (1, 1, 1) or its local transformation scale. Changes to the local transformation scale are preserved.
Returns whether this node uses a scale of (1, 1, 1) or its local transformation scale.
Returns the current resource this node is registered to.
Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations.
Updates the of this node.
Returns true if the node is present in the , its property is true and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree.
Enables rendering of this node. Changes to true.
Disables rendering of this node. Changes to false.
Sets whether the node notifies about its local transformation changes. will not propagate this by default.
Returns whether node notifies about its local transformation changes. will not propagate this by default.
Sets whether the node notifies about its global and local transformation changes. will not propagate this by default, unless it is in the editor context and it has a valid gizmo.
Returns whether the node notifies about its global and local transformation changes. will not propagate this by default.
Rotates the local transformation around axis, a unit , by specified angle in radians.
Rotates the global (world) transformation around axis, a unit , by specified angle in radians. The rotation axis is in global coordinate system.
Scales the global (world) transformation by the given scale factors.
Moves the global (world) transformation by offset. The offset is in global coordinate system.
Rotates the local transformation around axis, a unit , by specified angle in radians. The rotation axis is in object-local coordinate system.
Scales the local transformation by given 3D scale factors in object-local coordinate system.
Changes the node's position by the given offset in local space.
Rotates the local transformation around the X axis by angle in radians.
Rotates the local transformation around the Y axis by angle in radians.
Rotates the local transformation around the Z axis by angle in radians.
Changes the node's position by the given offset .
Note that the translation offset is affected by the node's scale, so if scaled by e.g. (10, 1, 1), a translation by an offset of (2, 0, 0) would actually add 20 (2 * 10) to the X coordinate.
Resets this node's transformations (like scale, skew and taper) preserving its rotation and translation by performing Gram-Schmidt orthonormalization on this node's .
Reset all transformations for this node (sets its to the identity matrix).
Rotates the node so that the local forward axis (-Z) points toward the target position.
The local up axis (+Y) points as close to the up vector as possible while staying perpendicular to the local forward axis. The resulting transform is orthogonal, and the scale is preserved. Non-uniform scaling may not work correctly.
The target position cannot be the same as the node's position, the up vector cannot be zero, and the direction from the node's position to the target vector cannot be parallel to the up vector.
Operations take place in global space.
Moves the node to the specified position, and then rotates itself to point toward the target as per . Operations take place in global space.
Transforms global_point from world space to this node's local space.
Transforms local_point from this node's local space to world space.
This provides a default material with a wide variety of rendering features and properties without the need to write shader code. See the tutorial below for details.
The real conditioned shader needed on each situation will be sent for background compilation. In the meantime, a very complex shader that adapts to every situation will be used ("ubershader"). This ubershader is much slower to render, but will keep the game running without stalling to compile. Once shader compilation is done, the ubershader is replaced by the traditional optimized shader.
Anything with this material applied won't be rendered while this material's shader is being compiled.
This is useful for optimization, in cases where the visuals won't suffer from having certain non-essential elements missing during the short time their shaders are being compiled.
Adds the emission color to the color from the emission texture.
Multiplies the emission color by the color from the emission texture.
Default diffuse scattering algorithm.
Diffuse scattering ignores roughness.
Extends Lambert to cover more than 90 degrees when roughness increases.
Attempts to use roughness to emulate microsurfacing.
Uses a hard cut for lighting, with smoothing affected by roughness.
Default specular blob.
Older specular algorithm, included for compatibility.
Older specular algorithm, included for compatibility.
Toon blob which changes size based on roughness.
No specular blob.
Constant for setting .
Constant for setting .
Constant for setting .
Constant for setting .
Constant for setting .
Constant for setting .
Constant for setting .
Constant for setting .
Constant for setting .
Constant for setting .
Constant for setting .
Constant for setting .
Represents the size of the enum.
No lighting is used on the object. Color comes directly from ALBEDO.
Lighting is calculated per-vertex rather than per-pixel. This can be used to increase the speed of the shader at the cost of quality.
Disables the depth test, so this object is drawn on top of all others. However, objects drawn after it in the draw order may cover it.
Set ALBEDO to the per-vertex color specified in the mesh.
Vertex color is in sRGB space and needs to be converted to linear. Only applies in the GLES3 renderer.
Uses point size to alter the size of primitive points. Also changes the albedo texture lookup to use POINT_COORD instead of UV.
Object is scaled by depth so that it always appears the same size on screen.
Shader will keep the scale set for the mesh. Otherwise the scale is lost when billboarding. Only applies when is .
Use triplanar texture lookup for all texture lookups that would normally use UV.
Use triplanar texture lookup for all texture lookups that would normally use UV2.
Use UV2 coordinates to look up from the .
Use UV2 coordinates to look up from the .
Use alpha scissor. Set by .
Use world coordinates in the triplanar texture lookup instead of local coordinates.
Forces the shader to convert albedo from sRGB space to linear space.
Disables receiving shadows from other objects.
Disables receiving ambient light.
Ensures that normals appear correct, even with non-uniform scaling.
Enables the shadow to opacity feature.
Enables signed distance field rendering shader.
Represents the size of the enum.
Default cull mode. The back of the object is culled when not visible.
The front of the object is culled when not visible.
No culling is performed.
Use UV with the detail texture.
Use UV2 with the detail texture.
Do not use distance fade.
Smoothly fades the object out based on each pixel's distance from the camera using the alpha channel.
Smoothly fades the object out based on each pixel's distance from the camera using a dither approach. Dithering discards pixels based on a set pattern to smoothly fade without enabling transparency. On certain hardware this can be faster than .
Smoothly fades the object out based on the object's distance from the camera using a dither approach. Dithering discards pixels based on a set pattern to smoothly fade without enabling transparency. On certain hardware this can be faster than .
Billboard mode is disabled.
The object's Z axis will always face the camera.
The object's X axis will always face the camera.
Used for particle systems when assigned to and nodes. Enables particles_anim_* properties.
The or should also be set to a positive value for the animation to play.
Default depth draw mode. Depth is drawn only for opaque objects.
Depth draw is calculated for both opaque and transparent objects.
No depth draw.
For transparent objects, an opaque pass is made first with the opaque parts, then transparency is drawn.
Used to read from the red channel of a texture.
Used to read from the green channel of a texture.
Used to read from the blue channel of a texture.
Used to read from the alpha channel of a texture.
Currently unused.
Default blend mode. The color of the object is blended over the background based on the object's alpha value.
The color of the object is added to the background.
The color of the object is subtracted from the background.
The color of the object is multiplied by the background.
Texture specifying per-pixel color.
Texture specifying per-pixel metallic value.
Texture specifying per-pixel roughness value.
Texture specifying per-pixel emission color.
Texture specifying per-pixel normal vector.
Texture specifying per-pixel rim value.
Texture specifying per-pixel clearcoat value.
Texture specifying per-pixel flowmap direction for use with .
Texture specifying per-pixel ambient occlusion value.
Texture specifying per-pixel depth.
Texture specifying per-pixel subsurface scattering.
Texture specifying per-pixel transmission color.
Texture specifying per-pixel refraction strength.
Texture specifying per-pixel detail mask blending value.
Texture specifying per-pixel detail color.
Texture specifying per-pixel detail normal.
Represents the size of the enum.
If true, transparency is enabled on the body. See also .
If true, enables the "shadow to opacity" render mode where lighting modifies the alpha so shadowed areas are opaque and non-shadowed areas are transparent. Useful for overlaying shadows onto a camera feed in AR.
If true, the object is unaffected by lighting.
If true, lighting is calculated per vertex rather than per pixel. This may increase performance on low-end devices, especially for meshes with a lower polygon count. The downside is that shading becomes much less accurate, with visible linear interpolation between vertices that are joined together. This can be compensated by ensuring meshes have a sufficient level of subdivision (but not too much, to avoid reducing performance). Some material features are also not supported when vertex shading is enabled.
See also which can globally enable vertex shading on all materials.
Note: By default, vertex shading is enforced on mobile platforms by 's mobile override.
Note: has no effect if is true.
If true, depth testing is disabled and the object will be drawn in render order.
If true, render point size can be changed.
Note: This is only effective for objects whose geometry is point-based rather than triangle-based. See also .
If true, triplanar mapping is calculated in world space rather than object local space. See also .
If true, the object is rendered at the same size regardless of distance.
Forces a conversion of the from sRGB space to linear space.
If true, the object receives no shadow that would otherwise be cast onto it.
If true, the object receives no ambient light.
If true, the shader will compute extra operations to make sure the normal stays correct when using a non-uniform scale. Only enable if using non-uniform scaling.
Enables signed distance field rendering shader.
If true, the vertex color is used as albedo color.
If true, the model's vertex colors are processed as sRGB mode.
The algorithm used for diffuse light scattering. See .
The method for rendering the specular blob. See .
The material's blend mode.
Note: Values other than Mix force the object into the transparent pipeline. See .
Which side of the object is not drawn when backfaces are rendered. See .
Determines when depth rendering takes place. See . See also .
Currently unimplemented in Godot.
The point size in pixels. See .
Controls how the object faces the camera. See .
Note: Billboard mode is not suitable for VR because the left-right vector of the camera is not horizontal when the screen is attached to your head instead of on the table. See GitHub issue #41567 for details.
If true, the shader will keep the scale set for the mesh. Otherwise the scale is lost when billboarding. Only applies when is .
If true, enables the vertex grow setting. See .
Grows object vertices in the direction of their normals.
If true, the shader will discard all pixels that have an alpha value less than .
Threshold at which the alpha scissor will discard values.
The number of horizontal frames in the particle sprite sheet. Only enabled when using . See .
The number of vertical frames in the particle sprite sheet. Only enabled when using . See .
If true, particle animations are looped. Only enabled when using . See .
The material's base color.
Texture to multiply by . Used for basic texturing of objects.
A high value makes the material appear more like a metal. Non-metals use their albedo as the diffuse color and add diffuse to the specular reflection. With non-metals, the reflection appears on top of the albedo color. Metals use their albedo as a multiplier to the specular reflection and set the diffuse color to black resulting in a tinted reflection. Materials work better when fully metal or fully non-metal, values between 0 and 1 should only be used for blending between metal and non-metal sections. To alter the amount of reflection use .
Sets the size of the specular lobe. The specular lobe is the bright spot that is reflected from light sources.
Note: Unlike , this is not energy-conserving, so it should be left at 0.5 in most cases. See also .
Texture used to specify metallic for an object. This is multiplied by .
Specifies the channel of the in which the metallic information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use.
Surface reflection. A value of 0 represents a perfect mirror while a value of 1 completely blurs the reflection. See also .
Texture used to control the roughness per-pixel. Multiplied by .
Specifies the channel of the in which the ambient occlusion information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use.
If true, the body emits light. Emitting light makes the object appear brighter. The object can also cast light on other objects if a or is used and this object is used in baked lighting.
The emitted light's color. See .
The emitted light's strength. See .
Sets how interacts with . Can either add or multiply. See for options.
Use UV2 to read from the .
Texture that specifies how much surface emits light at a given point.
If true, normal mapping is enabled.
The strength of the normal map's effect.
Texture used to specify the normal at a given pixel. The normal_texture only uses the red and green channels; the blue and alpha channels are ignored. The normal read from normal_texture is oriented around the surface normal provided by the .
Note: The mesh must have both normals and tangents defined in its vertex data. Otherwise, the normal map won't render correctly and will only appear to darken the whole surface. If creating geometry with , you can use and to automatically generate normals and tangents respectively.
Note: Godot expects the normal map to use X+, Y+, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.
If true, rim effect is enabled. Rim lighting increases the brightness at glancing angles on an object.
Note: Rim lighting is not visible if the material has set to true.
Sets the strength of the rim lighting effect.
The amount of to blend light and albedo color when rendering rim effect. If 0 the light color is used, while 1 means albedo color is used. An intermediate value generally works best.
Texture used to set the strength of the rim lighting effect per-pixel. Multiplied by .
If true, clearcoat rendering is enabled. Adds a secondary transparent pass to the lighting calculation resulting in an added specular blob. This makes materials appear as if they have a clear layer on them that can be either glossy or rough.
Note: Clearcoat rendering is not visible if the material has set to true.
Sets the strength of the clearcoat effect. Setting to 0 looks the same as disabling the clearcoat effect.
Sets the roughness of the clearcoat pass. A higher value results in a smoother clearcoat while a lower value results in a rougher clearcoat.
Texture that defines the strength of the clearcoat effect and the glossiness of the clearcoat. Strength is specified in the red channel while glossiness is specified in the green channel.
If true, anisotropy is enabled. Anisotropy changes the shape of the specular blob and aligns it to tangent space. This is useful for brushed aluminium and hair reflections.
Note: Mesh tangents are needed for anisotropy to work. If the mesh does not contain tangents, the anisotropy effect will appear broken.
Note: Material anisotropy should not to be confused with anisotropic texture filtering. Anisotropic texture filtering can be enabled by selecting a texture in the FileSystem dock, going to the Import dock, checking the Anisotropic checkbox then clicking Reimport. The anisotropic filtering level can be changed by adjusting .
The strength of the anisotropy effect. This is multiplied by 's alpha channel if a texture is defined there and the texture contains an alpha channel.
Texture that offsets the tangent map for anisotropy calculations and optionally controls the anisotropy effect (if an alpha channel is present). The flowmap texture is expected to be a derivative map, with the red channel representing distortion on the X axis and green channel representing distortion on the Y axis. Values below 0.5 will result in negative distortion, whereas values above 0.5 will result in positive distortion.
If present, the texture's alpha channel will be used to multiply the strength of the effect. Fully opaque pixels will keep the anisotropy effect's original strength while fully transparent pixels will disable the anisotropy effect entirely. The flowmap texture's blue channel is ignored.
If true, ambient occlusion is enabled. Ambient occlusion darkens areas based on the .
Amount that ambient occlusion affects lighting from lights. If 0, ambient occlusion only affects ambient light. If 1, ambient occlusion affects lights just as much as it affects ambient light. This can be used to impact the strength of the ambient occlusion effect, but typically looks unrealistic.
Texture that defines the amount of ambient occlusion for a given point on the object.
If true, use UV2 coordinates to look up from the .
Specifies the channel of the in which the ambient occlusion information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use.
If true, depth mapping is enabled (also called "parallax mapping" or "height mapping"). See also .
Note: Depth mapping is not supported if triplanar mapping is used on the same material. The value of will be ignored if is enabled.
Scales the depth offset effect. A higher number will create a larger depth.
If true, the shader will read depth texture at multiple points along the view ray to determine occlusion and parrallax. This can be very performance demanding, but results in more realistic looking depth mapping.
Number of layers to use when using and the view direction is parallel to the surface of the object. A higher number will be more performance demanding while a lower number may not look as crisp.
Number of layers to use when using and the view direction is perpendicular to the surface of the object. A higher number will be more performance demanding while a lower number may not look as crisp.
If true, direction of the tangent is flipped before using in the depth effect. This may be necessary if you have encoded your tangents in a way that is conflicting with the depth effect.
If true, direction of the binormal is flipped before using in the depth effect. This may be necessary if you have encoded your binormals in a way that is conflicting with the depth effect.
Texture used to determine depth at a given pixel. Depth is always stored in the red channel.
If true, subsurface scattering is enabled. Emulates light that penetrates an object's surface, is scattered, and then emerges.
The strength of the subsurface scattering effect.
Texture used to control the subsurface scattering strength. Stored in the red texture channel. Multiplied by .
If true, the transmission effect is enabled.
The color used by the transmission effect. Represents the light passing through an object.
Texture used to control the transmission effect per-pixel. Added to .
If true, the refraction effect is enabled. Refraction distorts transparency based on light from behind the object. When using the GLES3 backend, the material's roughness value will affect the blurriness of the refraction. Higher roughness values will make the refraction look blurrier.
The strength of the refraction effect. Higher values result in a more distorted appearance for the refraction.
Texture that controls the strength of the refraction per-pixel. Multiplied by .
Specifies the channel of the in which the refraction information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use.
If true, enables the detail overlay. Detail is a second texture that gets mixed over the surface of the object based on . This can be used to add variation to objects, or to blend between two different albedo/normal textures.
Texture used to specify how the detail textures get blended with the base textures.
Specifies how the should blend with the current ALBEDO. See for options.
Specifies whether to use UV or UV2 for the detail layer. See for options.
Texture that specifies the color of the detail overlay.
Texture that specifies the per-pixel normal of the detail overlay.
Note: Godot expects the normal map to use X+, Y+, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.
How much to scale the UV coordinates. This is multiplied by UV in the vertex function.
How much to offset the UV coordinates. This amount will be added to UV in the vertex function. This can be used to offset a texture.
If true, instead of using UV textures will use a triplanar texture lookup to determine how to apply textures. Triplanar uses the orientation of the object's surface to blend between texture coordinates. It reads from the source texture 3 times, once for each axis and then blends between the results based on how closely the pixel aligns with each axis. This is often used for natural features to get a realistic blend of materials. Because triplanar texturing requires many more texture reads per-pixel it is much slower than normal UV texturing. Additionally, because it is blending the texture between the three axes, it is unsuitable when you are trying to achieve crisp texturing.
A lower number blends the texture more softly while a higher number blends the texture more sharply.
How much to scale the UV2 coordinates. This is multiplied by UV2 in the vertex function.
How much to offset the UV2 coordinates. This amount will be added to UV2 in the vertex function. This can be used to offset a texture.
If true, instead of using UV2 textures will use a triplanar texture lookup to determine how to apply textures. Triplanar uses the orientation of the object's surface to blend between texture coordinates. It reads from the source texture 3 times, once for each axis and then blends between the results based on how closely the pixel aligns with each axis. This is often used for natural features to get a realistic blend of materials. Because triplanar texturing requires many more texture reads per-pixel it is much slower than normal UV texturing. Additionally, because it is blending the texture between the three axes, it is unsuitable when you are trying to achieve crisp texturing.
A lower number blends the texture more softly while a higher number blends the texture more sharply.
If true, the proximity fade effect is enabled. The proximity fade effect fades out each pixel based on its distance to another object.
Distance over which the fade effect takes place. The larger the distance the longer it takes for an object to fade.
Specifies which type of fade to use. Can be any of the s.
Distance at which the object starts to become visible. If the object is less than this distance away, it will be invisible.
Note: If distance_fade_min_distance is greater than distance_fade_max_distance, the behavior will be reversed. The object will start to fade away at distance_fade_max_distance and will fully disappear once it reaches distance_fade_min_distance.
Distance at which the object appears fully opaque.
Note: If distance_fade_max_distance is less than distance_fade_min_distance, the behavior will be reversed. The object will start to fade away at distance_fade_max_distance and will fully disappear once it reaches distance_fade_min_distance.
If is Synchronous (with or without cache), this determines how this material must behave in regards to asynchronous shader compilation.
is the default and the best for most cases.
If true, enables the specified flag. Flags are optional behavior that can be turned on and off. Only one flag can be enabled at a time with this function, the flag enumerators cannot be bit-masked together to enable or disable multiple flags at once. Flags can also be enabled by setting the corresponding member to true. See enumerator for options.
Returns true, if the specified flag is enabled. See enumerator for options.
If true, enables the specified . Many features that are available in s need to be enabled before use. This way the cost for using the feature is only incurred when specified. Features can also be enabled by setting the corresponding member to true.
Returns true, if the specified is enabled.
Sets the to be used by the specified . This function is called when setting members ending in *_texture.
Returns the associated with the specified .
Class representing a spherical .
Radius of sphere.
Full height of the sphere.
Number of radial segments on the sphere.
Number of segments along the height of the sphere.
If true, a hemisphere is created rather than a full sphere.
Note: To get a regular hemisphere, the height and radius of the sphere must be equal.
Sphere shape for 3D collisions, which can be set into a or . This shape is useful for modeling sphere-like 3D objects.
The sphere's radius. The shape's diameter is double the radius.
SpinBox is a numerical input text field. It allows entering integers and floats.
Example:
var spin_box = SpinBox.new()
add_child(spin_box)
var line_edit = spin_box.get_line_edit()
line_edit.context_menu_enabled = false
spin_box.align = LineEdit.ALIGN_RIGHT
The above code will create a , disable context menu on it and set the text alignment to right.
See class for more options over the .
Note: relies on an underlying node. To theme a 's background, add theme items for and customize them.
Note: If you want to implement drag and drop for the underlying , you can use on the node returned by .
Sets the text alignment of the .
If true, the will be editable. Otherwise, it will be read only.
Adds the specified prefix string before the numerical value of the .
Adds the specified suffix string after the numerical value of the .
Applies the current value of this .
Returns the instance from this . You can use it to access properties and methods of .
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Container for splitting two s vertically or horizontally, with a grabber that allows adjusting the split offset or ratio.
The split dragger is visible when the cursor hovers it.
The split dragger is never visible.
The split dragger is never visible and its space collapsed.
The initial offset of the splitting between the two s, with 0 being at the end of the first .
If true, the area of the first will be collapsed and the dragger will be disabled.
Determines the dragger's visibility. See for details.
Clamps the value to not go outside the currently possible minimal and maximum values.
A Spotlight is a type of node that emits lights in a specific direction, in the shape of a cone. The light is attenuated through the distance. This attenuation can be configured by changing the energy, radius and attenuation parameters of .
Note: By default, only 32 SpotLights may affect a single mesh resource at once. Consider splitting your level into several meshes to decrease the likelihood that more than 32 lights will affect the same mesh resource. Splitting the level mesh will also improve frustum culling effectiveness, leading to greater performance. If you need to use more lights per mesh, you can increase at the cost of shader compilation times.
The maximal range that can be reached by the spotlight. Note that the effectively lit area may appear to be smaller depending on the in use. No matter the in use, the light will never reach anything outside this range.
The spotlight's light energy attenuation curve.
The spotlight's angle in degrees.
The spotlight's angular attenuation curve.
The SpringArm node is a node that casts a ray (or collision shape) along its z axis and moves all its direct children to the collision point, minus a margin.
The most common use case for this is to make a 3rd person camera that reacts to collisions in the environment.
The SpringArm will either cast a ray, or if a shape is given, it will cast the shape in the direction of its z axis.
If you use the SpringArm as a camera controller for your player, you might need to exclude the player's collider from the SpringArm's collision check.
The layers against which the collision check shall be done. See Collision layers and masks in the documentation for more information.
The to use for the SpringArm.
When the shape is set, the SpringArm will cast the on its z axis instead of performing a ray cast.
The maximum extent of the SpringArm. This is used as a length for both the ray and the shape cast used internally to calculate the desired position of the SpringArm's child nodes.
To know more about how to perform a shape cast or a ray cast, please consult the documentation.
When the collision check is made, a candidate length for the SpringArm is given.
The margin is then subtracted to this length and the translation is applied to the child objects of the SpringArm.
This margin is useful for when the SpringArm has a as a child node: without the margin, the would be placed on the exact point of collision, while with the margin the would be placed close to the point of collision.
Returns the spring arm's current length.
Adds the object with the given to the list of objects excluded from the collision check.
Removes the given from the list of objects excluded from the collision check.
Clears the list of objects excluded from the collision check.
A node that displays a 2D texture. The texture displayed can be a region from a larger atlas texture, or a frame from a sprite sheet animation.
object to draw.
The normal map gives depth to the Sprite.
Note: Godot expects the normal map to use X+, Y-, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.
If true, texture is centered.
The texture's drawing offset.
If true, texture is flipped horizontally.
If true, texture is flipped vertically.
The number of columns in the sprite sheet.
The number of rows in the sprite sheet.
Current frame to display from sprite sheet. or must be greater than 1.
Coordinates of the frame to display from sprite sheet. This is as an alias for the property. or must be greater than 1.
If true, texture is cut from a larger atlas texture. See .
The region of the atlas texture to display. must be true.
If true, the outermost pixels get blurred out.
Returns true, if the pixel at the given position is opaque and false in other case.
Note: It also returns false, if the sprite's texture is null or if the given position is invalid.
Returns a representing the Sprite's boundary in local coordinates. Can be used to detect if the Sprite was clicked. Example:
func _input(event):
if event is InputEventMouseButton and event.pressed and event.button_index == BUTTON_LEFT:
if get_rect().has_point(to_local(event.position)):
print("A click!")
A node that displays a 2D texture in a 3D environment. The texture displayed can be a region from a larger atlas texture, or a frame from a sprite sheet animation.
object to draw. If is used, this will be overridden. The size information is still used.
The number of columns in the sprite sheet.
The number of rows in the sprite sheet.
Current frame to display from sprite sheet. or must be greater than 1.
Coordinates of the frame to display from sprite sheet. This is as an alias for the property. or must be greater than 1.
If true, texture will be cut from a larger atlas texture. See .
The region of the atlas texture to display. must be true.
A node that displays 2D texture information in a 3D environment.
If set, the texture's transparency and the opacity are used to make those parts of the sprite invisible.
If set, lights in the environment affect the sprite.
If set, texture can be seen from the back as well, if not, it is invisible when looking at it from behind.
Disables the depth test, so this object is drawn on top of all others. However, objects drawn after it in the draw order may cover it.
Sprite is scaled by depth so that it always appears the same size on screen.
Represents the size of the enum.
If true, texture will be centered.
The texture's drawing offset.
If true, texture is flipped horizontally.
If true, texture is flipped vertically.
A color value used to multiply the texture's colors. Can be used for mood-coloring or to simulate the color of light.
Note: If a is defined on the , the material override must be configured to take vertex colors into account for albedo. Otherwise, the color defined in will be ignored. For a , must be true. For a , ALBEDO *= COLOR.rgb; must be inserted in the shader's fragment() function.
The texture's visibility on a scale from 0 (fully invisible) to 1 (fully visible). is a multiplier for the color's alpha channel.
Note: If a is defined on the , the material override must be configured to take vertex colors into account for albedo. Otherwise, the opacity defined in will be ignored. For a , must be true. For a , ALPHA *= COLOR.a; must be inserted in the shader's fragment() function.
The size of one pixel's width on the sprite to scale it in 3D.
The direction in which the front of the texture faces.
If true, the texture's transparency and the opacity are used to make those parts of the sprite invisible.
If true, the in the has effects on the sprite.
If true, texture can be seen from the back as well, if false, it is invisible when looking at it from behind.
If true, depth testing is disabled and the object will be drawn in render order.
If true, the label is rendered at the same size regardless of distance.
Sets the render priority for the sprite. Higher priority objects will be sorted in front of lower priority objects.
Note: This only applies if is set to (default value).
Note: This only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority).
If true, the specified flag will be enabled.
Returns the value of the specified flag.
Returns the rectangle representing this sprite.
Sprite frame library for an or node. Contains frames and animation data for playback.
Note: You can associate a set of normal maps by creating additional resources with a _normal suffix. For example, having 2 resources run and run_normal will make it so the run animation uses the normal map.
Compatibility property, always equals to an empty array.
Adds a new animation to the library.
If true, the named animation exists.
Removes the given animation.
Changes the animation's name to newname.
Returns an array containing the names associated to each animation. Values are placed in alphabetical order.
The animation's speed in frames per second.
The animation's speed in frames per second.
If true, the animation will loop.
Returns true if the given animation is configured to loop when it finishes playing. Otherwise, returns false.
Adds a frame to the given animation.
Returns the number of frames in the animation.
Returns the animation's selected frame.
Sets the texture of the given frame.
Removes the animation's selected frame.
Removes all frames from the given animation.
Removes all animations. A "default" animation will be created.
Static body for 3D physics. A static body is a simple body that is not intended to move. In contrast to , they don't consume any CPU resources as long as they don't move.
Additionally, a constant linear or angular velocity can be set for the static body, so even if it doesn't move, it affects other bodies as if it was moving (this is useful for simulating conveyor belts or conveyor wheels).
The body's friction, from 0 (frictionless) to 1 (full friction).
Deprecated, use instead via .
The body's bounciness. Values range from 0 (no bounce) to 1 (full bounciness).
Deprecated, use instead via .
The physics material override for the body.
If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
The body's constant linear velocity. This does not move the body, but affects other bodies that touch it, as if it was in a state of movement.
The body's constant angular velocity. This does not rotate the body, but affects other bodies that touch it, as if it was in a state of rotation.
Static body for 2D physics. A StaticBody2D is a body that is not intended to move. It is ideal for implementing objects in the environment, such as walls or platforms.
Additionally, a constant linear or angular velocity can be set for the static body, which will affect colliding bodies as if it were moving (for example, a conveyor belt).
The body's constant linear velocity. This does not move the body, but affects colliding bodies, as if it were moving.
The body's constant angular velocity. This does not rotate the body, but affects colliding bodies, as if it were rotating.
The body's friction. Values range from 0 (no friction) to 1 (full friction).
Deprecated, use instead via .
The body's bounciness. Values range from 0 (no bounce) to 1 (full bounciness).
Deprecated, use instead via .
The physics material override for the body.
If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
StreamPeer is an abstraction and base class for stream-based protocols (such as TCP). It provides an API for sending and receiving data through streams as raw data or strings.
If true, this will using big-endian format for encoding and decoding.
Sends a chunk of data through the connection, blocking if necessary until the data is done sending. This function returns an code.
Sends a chunk of data through the connection. If all the data could not be sent at once, only part of it will. This function returns two values, an code and an integer, describing how much data was actually sent.
Returns a chunk data with the received bytes. The amount of bytes to be received can be requested in the bytes argument. If not enough bytes are available, the function will block until the desired amount is received. This function returns two values, an code and a data array.
Returns a chunk data with the received bytes. The amount of bytes to be received can be requested in the "bytes" argument. If not enough bytes are available, the function will return how many were actually received. This function returns two values, an code, and a data array.
Returns the amount of bytes this has available.
Puts a signed byte into the stream.
Puts an unsigned byte into the stream.
Puts a signed 16-bit value into the stream.
Puts an unsigned 16-bit value into the stream.
Puts a signed 32-bit value into the stream.
Puts an unsigned 32-bit value into the stream.
Puts a signed 64-bit value into the stream.
Puts an unsigned 64-bit value into the stream.
Puts a single-precision float into the stream.
Puts a double-precision float into the stream.
Puts a zero-terminated ASCII string into the stream prepended by a 32-bit unsigned integer representing its size.
Note: To put an ASCII string without prepending its size, you can use :
put_data("Hello world".to_ascii())
Puts a zero-terminated UTF-8 string into the stream prepended by a 32 bits unsigned integer representing its size.
Note: To put an UTF-8 string without prepending its size, you can use :
put_data("Hello world".to_utf8())
Puts a Variant into the stream. If full_objects is true encoding objects is allowed (and can potentially include code).
Gets a signed byte from the stream.
Gets an unsigned byte from the stream.
Gets a signed 16-bit value from the stream.
Gets an unsigned 16-bit value from the stream.
Gets a signed 32-bit value from the stream.
Gets an unsigned 32-bit value from the stream.
Gets a signed 64-bit value from the stream.
Gets an unsigned 64-bit value from the stream.
Gets a single-precision float from the stream.
Gets a double-precision float from the stream.
Gets an ASCII string with byte-length bytes from the stream. If bytes is negative (default) the length will be read from the stream using the reverse process of .
Gets an UTF-8 string with byte-length bytes from the stream (this decodes the string sent as UTF-8). If bytes is negative (default) the length will be read from the stream using the reverse process of .
Gets a Variant from the stream. If allow_objects is true, decoding objects is allowed.
Warning: Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
Data buffer stream peer that uses a byte array as the stream. This object can be used to handle binary data from network sessions. To handle binary data stored in files, can be used directly.
A object keeps an internal cursor which is the offset in bytes to the start of the buffer. Get and put operations are performed at the cursor position and will move the cursor accordingly.
The underlying data buffer. Setting this value resets the cursor.
Moves the cursor to the specified position. position must be a valid index of .
Returns the size of .
Returns the current cursor position.
Resizes the . This doesn't update the cursor.
Clears the and resets the cursor.
Returns a new with the same content.
SSL stream peer. This object can be used to connect to an SSL server or accept a single SSL client connection.
A status representing a that is disconnected.
A status representing a during handshaking.
A status representing a that is connected to a host.
A status representing a in error state.
An error status that shows a mismatch in the SSL certificate domain presented by the host and the domain requested for validation.
Poll the connection to check for incoming bytes. Call this right before for it to work properly.
Accepts a peer connection as a server using the given private_key and providing the given certificate to the client. You can pass the optional chain parameter to provide additional CA chain information along with the certificate.
Connects to a peer using an underlying stream. If validate_certs is true, will validate that the certificate presented by the peer matches the for_hostname.
Note: Specifying a custom valid_certificate is not supported in HTML5 exports due to browsers restrictions.
Returns the status of the connection. See for values.
Disconnects from host.
TCP stream peer. This object can be used to connect to TCP servers, or also is returned by a TCP server.
The initial status of the . This is also the status after disconnecting.
A status representing a that is connecting to a host.
A status representing a that is connected to a host.
A status representing a in error state.
Connects to the specified host:port pair. A hostname will be resolved if valid. Returns OK on success or FAILED on failure.
Returns true if this peer is currently connected or is connecting to a host, false otherwise.
Returns the status of the connection, see .
Returns the IP of this peer.
Returns the port of this peer.
Disconnects from host.
If enabled is true, packets will be sent immediately. If enabled is false (the default), packet transfers will be delayed and combined using Nagle's algorithm.
Note: It's recommended to leave this disabled for applications that send large packets or need to transfer a lot of data, as enabling this can decrease the total available bandwidth.
A texture that is loaded from a .stex file.
The StreamTexture's file path to a .stex file.
Loads the texture from the given path.
StyleBox is that provides an abstract base class for drawing stylized boxes for the UI. StyleBoxes are used for drawing the styles of buttons, line edit backgrounds, tree backgrounds, etc. and also for testing a transparency mask for pointer signals. If mask test fails on a StyleBox assigned as mask to a control, clicks and motion signals will go through it to the one below.
Note: For children of that have Theme Properties, the focus is displayed over the normal, hover or pressed . This makes the focus more reusable across different nodes.
The left margin for the contents of this style box.Increasing this value reduces the space available to the contents from the left.
Refer to for extra considerations.
The right margin for the contents of this style box. Increasing this value reduces the space available to the contents from the right.
Refer to for extra considerations.
The top margin for the contents of this style box. Increasing this value reduces the space available to the contents from the top.
Refer to for extra considerations.
The bottom margin for the contents of this style box. Increasing this value reduces the space available to the contents from the bottom.
If this value is negative, it is ignored and a child-specific margin is used instead. For example for the border thickness (if any) is used instead.
It is up to the code using this style box to decide what these contents are: for example, a respects this content margin for the textual contents of the button.
should be used to fetch this value as consumer instead of reading these properties directly. This is because it correctly respects negative values and the fallback mentioned above.
Test a position in a rectangle, return whether it passes the mask test.
Sets the default value of the specified to given offset in pixels.
Returns the default value of the specified .
Returns the content margin offset for the specified .
Positive values reduce size inwards, unlike 's margin values.
Returns the minimum size that this stylebox can be shrunk to.
Returns the size of this without the margins.
Returns the "offset" of a stylebox. This helper function returns a value equivalent to Vector2(style.get_margin(MARGIN_LEFT), style.get_margin(MARGIN_TOP)).
Returns the that handles its or callback at this moment.
Draws this stylebox using a canvas item identified by the given .
The value can either be the result of called on an existing -derived node, or directly from creating a canvas item in the with .
Empty stylebox (really does not display anything).
This can be used to achieve all kinds of looks without the need of a texture. The following properties are customizable:
- Color
- Border width (individual width for each border)
- Rounded corners (individual radius for each corner)
- Shadow (with blur and offset)
Setting corner radius to high values is allowed. As soon as corners overlap, the stylebox will switch to a relative system. Example:
height = 30
corner_radius_top_left = 50
corner_radius_bottom_left = 100
The relative system now would take the 1:2 ratio of the two left corners to calculate the actual corner width. Both corners added will never be more than the height. Result:
corner_radius_top_left: 10
corner_radius_bottom_left: 20
The background color of the stylebox.
Toggles drawing of the inner part of the stylebox.
If set to a non-zero value on either axis, distorts the StyleBox horizontally and/or vertically. This can be used for "futuristic"-style UIs. Positive values skew the StyleBox towards the right (X axis) and upwards (Y axis), while negative values skew the StyleBox towards the left (X axis) and downwards (Y axis).
Note: To ensure text does not touch the StyleBox's edges, consider increasing the 's content margin (see ). It is preferable to increase the content margin instead of the expand margin (see ), as increasing the expand margin does not increase the size of the clickable area for s.
Border width for the left border.
Border width for the top border.
Border width for the right border.
Border width for the bottom border.
Sets the color of the border.
If true, the border will fade into the background color.
The top-left corner's radius. If 0, the corner is not rounded.
The top-right corner's radius. If 0, the corner is not rounded.
The bottom-right corner's radius. If 0, the corner is not rounded.
The bottom-left corner's radius. If 0, the corner is not rounded.
This sets the number of vertices used for each corner. Higher values result in rounder corners but take more processing power to compute. When choosing a value, you should take the corner radius () into account.
For corner radii less than 10, 4 or 5 should be enough. For corner radii less than 30, values between 8 and 12 should be enough.
A corner detail of 1 will result in chamfered corners instead of rounded corners, which is useful for some artistic effects.
Expands the stylebox outside of the control rect on the left edge. Useful in combination with to draw a border outside the control rect.
Note: Unlike , does not affect the size of the clickable area for s. This can negatively impact usability if used wrong, as the user may try to click an area of the StyleBox that cannot actually receive clicks.
Expands the stylebox outside of the control rect on the right edge. Useful in combination with to draw a border outside the control rect.
Note: Unlike , does not affect the size of the clickable area for s. This can negatively impact usability if used wrong, as the user may try to click an area of the StyleBox that cannot actually receive clicks.
Expands the stylebox outside of the control rect on the top edge. Useful in combination with to draw a border outside the control rect.
Note: Unlike , does not affect the size of the clickable area for s. This can negatively impact usability if used wrong, as the user may try to click an area of the StyleBox that cannot actually receive clicks.
Expands the stylebox outside of the control rect on the bottom edge. Useful in combination with to draw a border outside the control rect.
Note: Unlike , does not affect the size of the clickable area for s. This can negatively impact usability if used wrong, as the user may try to click an area of the StyleBox that cannot actually receive clicks.
The color of the shadow. This has no effect if is lower than 1.
The shadow size in pixels.
The shadow offset in pixels. Adjusts the position of the shadow relatively to the stylebox.
Antialiasing draws a small ring around the edges, which fades to transparency. As a result, edges look much smoother. This is only noticeable when using rounded corners or .
Note: When using beveled corners with 45-degree angles ( = 1), it is recommended to set to false to ensure crisp visuals and avoid possible visual glitches.
This changes the size of the faded ring. Higher values can be used to achieve a "blurry" effect.
Sets the border width to width pixels for all margins.
Returns the smallest border width out of all four borders.
Sets the border width to width pixels for the given margin. See for possible values.
Returns the given margin's border width. See for possible values.
Sets the corner radius for each corner to radius_top_left, radius_top_right, radius_bottom_right, and radius_bottom_left pixels.
Sets the corner radius to radius pixels for all corners.
Sets the corner radius to radius pixels for the given corner. See for possible values.
Returns the given corner's radius. See for possible values.
Sets the expand margin to size pixels for the given margin. See for possible values.
Sets the expand margin to size pixels for all margins.
Sets the expand margin for each margin to size_left, size_top, size_right, and size_bottom pixels.
Returns the size of the given margin's expand margin. See for possible values.
that displays a single line of a given color and thickness. It can be used to draw things like separators.
The line's color.
The number of pixels the line will extend before the 's bounds. If set to a negative value, the line will begin inside the 's bounds.
The number of pixels the line will extend past the 's bounds. If set to a negative value, the line will end inside the 's bounds.
The line's thickness in pixels.
If true, the line will be vertical. If false, the line will be horizontal.
Texture-based nine-patch , in a way similar to . This stylebox performs a 3×3 scaling of a texture, where only the center cell is fully stretched. This makes it possible to design bordered styles regardless of the stylebox's size.
Stretch the stylebox's texture. This results in visible distortion unless the texture size matches the stylebox's size perfectly.
Repeats the stylebox's texture to match the stylebox's size according to the nine-patch system.
Repeats the stylebox's texture to match the stylebox's size according to the nine-patch system. Unlike , the texture may be slightly stretched to make the nine-patch texture tile seamlessly.
The texture to use when drawing this style box.
The normal map to use when drawing this style box.
Note: Godot expects the normal map to use X+, Y-, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.
Species a sub-region of the texture to use.
This is equivalent to first wrapping the texture in an with the same region.
Increases the left margin of the 3×3 texture box.
A higher value means more of the source texture is considered to be part of the left border of the 3×3 box.
This is also the value used as fallback for if it is negative.
Increases the right margin of the 3×3 texture box.
A higher value means more of the source texture is considered to be part of the right border of the 3×3 box.
This is also the value used as fallback for if it is negative.
Increases the top margin of the 3×3 texture box.
A higher value means more of the source texture is considered to be part of the top border of the 3×3 box.
This is also the value used as fallback for if it is negative.
Increases the bottom margin of the 3×3 texture box.
A higher value means more of the source texture is considered to be part of the bottom border of the 3×3 box.
This is also the value used as fallback for if it is negative.
Expands the left margin of this style box when drawing, causing it to be drawn larger than requested.
Expands the right margin of this style box when drawing, causing it to be drawn larger than requested.
Expands the top margin of this style box when drawing, causing it to be drawn larger than requested.
Expands the bottom margin of this style box when drawing, causing it to be drawn larger than requested.
Controls how the stylebox's texture will be stretched or tiled horizontally. See for possible values.
Controls how the stylebox's texture will be stretched or tiled vertically. See for possible values.
Modulates the color of the texture when this style box is drawn.
If true, the nine-patch texture's center tile will be drawn.
Sets the margin to size pixels for the given margin. See for possible values.
Returns the size of the given margin. See for possible values.
Sets the expand margin to size pixels for the given margin. See for possible values.
Sets the expand margin to size pixels for all margins.
Sets the expand margin for each margin to size_left, size_top, size_right, and size_bottom pixels.
Returns the size of the given margin's expand margin. See for possible values.
The is used to construct a by specifying vertex attributes individually. It can be used to construct a from a script. All properties except indices need to be added before calling . For example, to add vertex colors and UVs:
var st = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.add_color(Color(1, 0, 0))
st.add_uv(Vector2(0, 0))
st.add_vertex(Vector3(0, 0, 0))
The above now contains one vertex of a triangle which has a UV coordinate and a specified . If another vertex were added without calling or , then the last values would be used.
Vertex attributes must be passed before calling . Failure to do so will result in an error when committing the vertex information to a mesh.
Additionally, the attributes used before the first vertex is added determine the format of the mesh. For example, if you only add UVs to the first vertex, you cannot add color to any of the subsequent vertices.
See also , and for procedural geometry generation.
Note: Godot uses clockwise winding order for front faces of triangle primitive modes.
Called before adding any vertices. Takes the primitive type as an argument (e.g. ).
Specifies the position of current vertex. Should be called after specifying other vertex properties (e.g. Color, UV).
Specifies a to use for the next vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
Note: The material must have enabled for the vertex color to be visible.
Specifies a normal to use for the next vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
Specifies a tangent to use for the next vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
Specifies a set of UV coordinates to use for the next vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
Specifies an optional second set of UV coordinates to use for the next vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
Specifies an array of bones to use for the next vertex. bones must contain 4 integers.
Specifies weight values to use for the next vertex. weights must contain 4 values. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
Specifies whether the current vertex (if using only vertex arrays) or current index (if also using index arrays) should use smooth normals for normal calculation.
Inserts a triangle fan made of array data into being constructed.
Requires the primitive type be set to .
If the parameter is null, then the default value is Array.Empty<Vector2>()
If the parameter is null, then the default value is Array.Empty<Color>()
If the parameter is null, then the default value is Array.Empty<Vector2>()
If the parameter is null, then the default value is Array.Empty<Vector3>()
If the parameter is null, then the default value is new Godot.Collections.Array { }
Adds an index to index array if you are using indexed vertices. Does not need to be called before adding vertices.
Shrinks the vertex array by creating an index array. This can improve performance by avoiding vertex reuse.
Removes the index array by expanding the vertex array.
Generates normals from vertices so you do not have to do it manually. If flip is true, the resulting normals will be inverted. should be called after generating geometry and before committing the mesh using or . For correct display of normal-mapped surfaces, you will also have to generate tangents using .
Note: only works if the primitive type to be set to .
Generates a tangent vector for each vertex. Requires that each vertex have UVs and normals set already (see ).
Sets to be used by the you are constructing.
Clear all information passed into the surface tool so far.
Creates a vertex array from an existing .
Creates a vertex array from the specified blend shape of an existing . This can be used to extract a specific pose from a blend shape.
Append vertices from a given surface onto the current vertex array with specified .
Note: Using on a is much slower as the GPU must communicate data back to the CPU, while also causing the main thread to stall (as OpenGL is not thread-safe). Consider requesting a copy of the mesh, converting it to an and adding vertices manually instead.
Returns a constructed from current information passed in. If an existing is passed in as an argument, will add an extra surface to the existing .
Default flag is if compression is enabled. If compression is disabled the default flag is . See ARRAY_COMPRESS_* constants in for other flags.
Commits the data to the same format used by . This way you can further process the mesh data using the API.
A TCP server. Listens to connections on a port and returns a when it gets an incoming connection.
Listen on the port binding to bind_address.
If bind_address is set as "*" (default), the server will listen on all available addresses (both IPv4 and IPv6).
If bind_address is set as "0.0.0.0" (for IPv4) or "::" (for IPv6), the server will listen on all available addresses matching that IP type.
If bind_address is set to any valid address (e.g. "192.168.1.101", "::1", etc), the server will only listen on the interface with that addresses (or fail if no interface with the given address exists).
Returns true if a connection is available for taking.
Returns true if the server is currently listening for connections.
If a connection is available, returns a StreamPeerTCP with the connection.
Stops listening.
Arranges children into a tabbed view, creating a tab for each one. The active tab's corresponding has its visible property set to true, and all other children's to false.
Ignores non- children.
Note: The drawing of the clickable tabs themselves is handled by this node. Adding as children is not needed.
Align the tabs to the left.
Align the tabs to the center.
Align the tabs to the right.
The alignment of all tabs in the tab container. See the constants for details.
The current tab index. When set, this index's node's visible property is set to true and all others are set to false.
If true, tabs are visible. If false, tabs' content and titles are hidden.
If true, all tabs are drawn in front of the panel. If false, inactive tabs are drawn behind the panel.
If true, tabs can be rearranged with mouse drag.
If true, children nodes that are hidden have their minimum size take into account in the total, instead of only the currently visible one.
Returns the number of tabs.
Returns the previously active tab index.
Returns the child node located at the active tab index.
Returns the node from the tab at index tab_idx.
Sets a title for the tab at index tab_idx. Tab titles default to the name of the indexed child node.
Returns the title of the tab at index tab_idx. Tab titles default to the name of the indexed child node, but this can be overridden with .
Sets an icon for the tab at index tab_idx.
Returns the for the tab at index tab_idx or null if the tab has no .
If disabled is true, disables the tab at index tab_idx, making it non-interactable.
Returns true if the tab at index tab_idx is disabled.
If hidden is true, hides the tab at index tab_idx, making it disappear from the tab area.
Returns true if the tab at index tab_idx is hidden.
Returns the index of the tab at local coordinates point. Returns -1 if the point is outside the control boundaries or if there's no tab at the queried position.
If set on a node instance, a popup menu icon appears in the top-right corner of the . Clicking it will expand the node.
Returns the node instance if one has been set already with .
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Defines rearrange group id, choose for each the same value to enable tab drag between . Enable drag with .
Returns the rearrange group id.
Simple tabs control, similar to but is only in charge of drawing tabs, not interacting with children.
Never show the close buttons.
Only show the close button on the currently active tab.
Show the close button on all tabs.
Represents the size of the enum.
Align the tabs to the left.
Align the tabs to the center.
Align the tabs to the right.
Represents the size of the enum.
Select tab at index tab_idx.
The alignment of all tabs. See for details.
Sets when the close button will appear on the tabs. See for details.
if true, the mouse's scroll wheel can be used to navigate the scroll view.
If true, tabs can be rearranged with mouse drag.
Returns the number of tabs.
Returns the previously active tab index.
Sets a title for the tab at index tab_idx.
Returns the title of the tab at index tab_idx.
Sets an icon for the tab at index tab_idx.
Returns the for the tab at index tab_idx or null if the tab has no .
Sets the button icon from the tab at index tab_idx.
Returns the button icon from the tab at index tab_idx.
If disabled is true, disables the tab at index tab_idx, making it non-interactable.
Returns true if the tab at index tab_idx is disabled.
Removes the tab at index tab_idx.
Adds a new tab.
Returns the number of hidden tabs offsetted to the left.
Returns true if the offset buttons (the ones that appear when there's not enough space for all tabs) are visible.
Moves the scroll view to make the tab visible.
Returns tab with local position and size.
Moves a tab from from to to.
Defines the rearrange group ID. Choose for each the same value to dragging tabs between . Enable drag with .
Returns the ' rearrange group ID.
If true, enables selecting a tab with the right mouse button.
Returns true if select with right mouse button is enabled.
TextEdit is meant for editing large, multiline text. It also has facilities for editing code, such as syntax highlighting support and multiple levels of undo/redo.
Note: When holding down Alt, the vertical scroll wheel will scroll 5 times as fast as it would normally do. This also works in the Godot script editor.
Match case when searching.
Match whole words when searching.
Search from end to beginning.
Used to access the result column from .
Used to access the result line from .
Cuts (copies and clears) the selected text.
Copies the selected text.
Pastes the clipboard text over the selected text (or at the cursor's position).
Erases the whole text.
Selects the whole text.
Undoes the previous action.
Redoes the previous action.
Represents the size of the enum.
String value of the .
If true, read-only mode is enabled. Existing text cannot be modified and new text cannot be added.
If true, the line containing the cursor is highlighted.
If true, any custom color properties that have been set for this will be visible.
If true, line numbers are displayed to the left of the text.
If true, the "tab" character will have a visible representation.
If true, the "space" character will have a visible representation.
If true, the bookmark gutter is visible.
If true, the breakpoint gutter is visible.
If true, the fold gutter is visible. This enables folding groups of indented lines.
If true, all occurrences of the selected text will be highlighted.
If true, custom font_color_selected will be used for selected text.
If true, a right-click displays the context menu.
If true, shortcut keys for context menu items are enabled, even if the context menu is disabled.
If true, the native virtual keyboard is shown when focused on platforms that support it.
If false, using middle mouse button to paste clipboard will be disabled.
Note: This method is only implemented on Linux.
If true, text can be selected.
If false, text can not be selected by the user or by the or methods.
If true, the selected text will be deselected when focus is lost.
If true, allow drag and drop of selected text.
If true, sets the step of the scrollbars to 0.25 which results in smoother scrolling.
Vertical scroll sensitivity.
If true, all lines that have been set to hidden by , will not be visible.
If true, enables text wrapping when it goes beyond the edge of what is visible.
If there is a vertical scrollbar, this determines the current vertical scroll value in line numbers, starting at 0 for the top line.
If there is a horizontal scrollbar, this determines the current horizontal scroll value in pixels.
If true, a minimap is shown, providing an outline of your source code.
The width, in pixels, of the minimap.
If true, the caret displays as a rectangle.
If false, the caret displays as a bar.
If true, the caret (visual cursor) blinks.
Duration (in seconds) of a caret's blinking cycle.
If true, a right-click moves the cursor at the mouse position before displaying the context menu.
If false, the context menu disregards mouse location.
Insert the specified text at the cursor position.
Returns the amount of total lines in the text.
Returns the text of a specific line.
Sets the text for a specific line.
Returns an array of s representing each wrapped index.
Returns the width in pixels of the wrap_index on line.
Returns the height of a largest line.
Returns if the given line is wrapped.
Returns the number of times the given line is wrapped.
Centers the viewport on the line the editing cursor is at. This also resets the value to 0.
Moves the cursor at the specified column index.
If adjust_viewport is set to true, the viewport will center at the cursor position after the move occurs.
Moves the cursor at the specified line index.
If adjust_viewport is set to true, the viewport will center at the cursor position after the move occurs.
If can_be_hidden is set to true, the specified line can be hidden using .
Returns the column the editing cursor is at.
Returns the line the editing cursor is at.
Returns the local position for the given line and column. If x or y of the returned vector equal -1, the position is outside of the viewable area of the control.
Note: The Y position corresponds to the bottom side of the line. Use to get the top side position.
Returns the local position and size for the grapheme at the given line and column. If x or y position of the returned rect equal -1, the position is outside of the viewable area of the control.
Note: The Y position of the returned rect corresponds to the top side of the line, unlike which returns the bottom side.
Returns the line and column at the given position. In the returned vector, x is the column, y is the line.
Returns true when the specified line is marked as safe.
If true, marks the line as safe.
This will show the line number with the color provided in the safe_line_number_color theme property.
Returns true when the specified line is bookmarked.
Bookmarks the line if bookmark is true. Deletes the bookmark if bookmark is false.
Bookmarks are shown in the .
Adds or removes the breakpoint in line. Breakpoints are shown in the .
Returns true when the specified line has a breakpoint.
Cut's the current selection.
Copy's the current text selection.
Paste the current selection.
Perform selection, from line/column to line/column.
If is false, no selection will occur.
Select all the text.
If is false, no selection will occur.
Deselects the current selection.
Returns true if the selection is active.
Returns the selection begin line.
Returns the selection begin column.
Returns the selection end line.
Returns the selection end column.
Returns the text inside the selection.
Returns whether the mouse is over selection. If edges is true, the edges are considered part of the selection.
Returns a text with the word under the caret (text cursor) location.
Perform a search inside the text. Search flags can be specified in the enum.
Returns an empty PoolIntArray if no result was found. Otherwise, the result line and column can be accessed at indices specified in the enum, e.g:
var result = search(key, flags, line, column)
if result.size() > 0:
# Result found.
var res_line = result[TextEdit.SEARCH_RESULT_LINE]
var res_column = result[TextEdit.SEARCH_RESULT_COLUMN]
Returns true if an "undo" action is available.
Returns true if a "redo" action is available.
Perform undo operation.
Perform redo operation.
Clears the undo history.
Returns the total width of all gutters and internal padding.
Returns the number of visible lines, including wrapped text.
Returns the total amount of lines that could be drawn.
If true, hides the line of the specified index.
Returns whether the line at the specified index is hidden or not.
Folds all lines that are possible to be folded (see ).
Unhide all lines that were previously set to hidden by .
Folds the given line, if possible (see ).
Unfolds the given line, if folded.
Toggle the folding of the code block at the given line.
Returns if the given line is foldable, that is, it has indented lines right below it.
Returns whether the line at the specified index is folded or not.
Adds a keyword and its .
Returns whether the specified keyword has a color set to it or not.
Returns the of the specified keyword.
Adds color region (given the delimiters) and its colors.
Clears all custom syntax coloring information previously added with or .
Triggers a right-click menu action by the specified index. See for a list of available indexes.
Returns the of this . By default, this menu is displayed when right-clicking on the .
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Returns an array containing the line number of each breakpoint.
Removes all the breakpoints. This will not fire the breakpoint_toggled signal.
Generate an from the text.
TextMesh can be generated only when using dynamic fonts with vector glyph contours. Bitmap fonts (including bitmap data in the TrueType/OpenType containers, like color emoji fonts) are not supported.
The UV layout is arranged in 4 horizontal strips, top to bottom: 40% of the height for the front face, 40% for the back face, 10% for the outer edges and 10% for the inner edges.
Align rows to the left (default).
Align rows centered.
Align rows to the right.
The text to generate mesh from.
used for the 's text.
Controls the text's horizontal alignment. Supports left, center and right. Set it to one of the constants.
If true, all the text displays as UPPERCASE.
The size of one pixel's width on the text to scale it in 3D.
Step (in pixels) used to approximate Bézier curves.
Depths of the mesh, if set to 0.0 only front surface, is generated, and UV layout is changed to use full texture for the front face only.
A texture works by registering an image in the video hardware, which then can be used in 3D models or 2D or GUI .
Textures are often created by loading them from a file. See @GDScript.load.
is a base for other resources. It cannot be used directly.
Note: The maximum texture size is 16384×16384 pixels due to graphics hardware limitations. Larger textures may fail to import.
Default flags. , and are enabled.
Generates mipmaps, which are smaller versions of the same texture to use when zoomed out, keeping the aspect ratio.
Repeats the texture (instead of clamp to edge).
Note: Ignored when using an as these don't support repetition.
Uses a magnifying filter, to enable smooth zooming in of the texture.
Uses anisotropic mipmap filtering. Generates smaller versions of the same texture with different aspect ratios.
This results in better-looking textures when viewed from oblique angles.
Converts the texture to the sRGB color space.
Repeats the texture with alternate sections mirrored.
Note: Ignored when using an as these don't support repetition.
Texture is a video surface.
The texture's . are used to set various properties of the .
Returns the texture width.
Returns the texture height.
Returns the texture size.
Returns true if this has an alpha channel.
Draws the texture using a with the API at the specified position. Equivalent to with a rect at position and the size of this .
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Draws the texture using a with the API. Equivalent to .
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Draws a part of the texture using a with the API. Equivalent to .
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Returns an that is a copy of data from this . s can be accessed and manipulated directly.
Texture3D is a 3-dimensional that has a width, height, and depth. See also .
Note: s can only be sampled in shaders in the GLES3 backend. In GLES2, their data can be accessed via scripting, but there is no way to render them in a hardware-accelerated manner.
Creates the Texture3D with specified width, height, and depth. See for format options. See enumerator for flags options.
s store an array of s in a single primitive. Each layer of the texture array has its own mipmap chain. This makes it is a good alternative to texture atlases. See also .
s must be displayed using shaders. After importing your file as a and setting the appropriate Horizontal and Vertical Slices, display it by setting it as a uniform to a shader, for example (2D):
shader_type canvas_item;
uniform sampler2DArray tex;
uniform int index;
void fragment() {
COLOR = texture(tex, vec3(UV.x, UV.y, float(index)));
}
Set the integer uniform "index" to show a particular part of the texture as defined by the Horizontal and Vertical Slices in the importer.
Note: When sampling an albedo texture from a texture array in 3D, the sRGB -> linear conversion hint (hint_albedo) should be used to prevent colors from looking washed out:
shader_type spatial;
uniform sampler2DArray tex : hint_albedo;
uniform int index;
void fragment() {
ALBEDO = texture(tex, vec3(UV.x, UV.y, float(index)));
}
Note: s can only be sampled in shaders in the GLES3 backend. In GLES2, their data can be accessed via scripting, but there is no way to render them in a hardware-accelerated manner.
Creates the TextureArray with specified width, height, and depth. See for format options. See enumerator for flags options.
has the same functionality as , except it uses sprites instead of Godot's resource. It is faster to create, but it doesn't support localization like more complex s.
The "normal" state must contain a texture (); other textures are optional.
See also which contains common properties and methods associated with this node.
Scale to fit the node's bounding rectangle.
Tile inside the node's bounding rectangle.
The texture keeps its original size and stays in the bounding rectangle's top-left corner.
The texture keeps its original size and stays centered in the node's bounding rectangle.
Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.
Scale the texture to fit the node's bounding rectangle, center it, and maintain its aspect ratio.
Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.
Texture to display by default, when the node is not in the disabled, focused, hover or pressed state.
Texture to display on mouse down over the node, if the node has keyboard focus and the player presses the Enter key or if the player presses the key.
Texture to display when the mouse hovers the node.
Texture to display when the node is disabled. See .
Texture to display when the node has mouse or keyboard focus.
Pure black and white image to use for click detection. On the mask, white pixels represent the button's clickable area. Use it to create buttons with curved shapes.
If true, the texture stretches to the edges of the node's bounding rectangle using the . If false, the texture will not scale with the node.
Controls the texture's behavior when you resize the node's bounding rectangle, only if is true. Set it to one of the constants. See the constants to learn more.
If true, texture is flipped horizontally.
If true, texture is flipped vertically.
Base class for and . Cannot be used directly, but contains all the functions necessary for accessing and using and . Data is set on a per-layer basis. For s, the layer specifies the depth or Z-index, they can be treated as a bunch of 2D slices. Similarly, for s, the layer specifies the array layer.
Default flags for . , and are enabled.
Default flags for . is enabled.
Texture will generate mipmaps on creation.
Texture will repeat when UV used is outside the 0-1 range.
Use filtering when reading from texture. Filtering smooths out pixels. Turning filtering off is slightly faster and more appropriate when you need access to individual pixels.
Uses anisotropic mipmap filtering. Generates smaller versions of the same texture with different aspect ratios.
This results in better-looking textures when viewed from oblique angles.
Specifies which apply to this texture.
Returns a dictionary with all the data used by this texture.
Returns the current format being used by this texture. See for details.
Returns the width of the texture. Width is typically represented by the X-axis.
Returns the height of the texture. Height is typically represented by the Y-axis.
Returns the depth of the texture. Depth is the 3rd dimension (typically Z-axis).
Sets the data for the specified layer. Data takes the form of a 2-dimensional resource.
Returns an resource with the data from specified layer.
Partially sets the data for a specified layer by overwriting using the data of the specified image. x_offset and y_offset determine where the is "stamped" over the texture. The image must fit within the texture.
TextureProgress works like , but uses up to 3 textures instead of Godot's resource. It can be used to create horizontal, vertical and radial progress bars.
The fills from left to right.
The fills from right to left.
The fills from top to bottom.
The fills from bottom to top.
Turns the node into a radial bar. The fills clockwise. See , and to control the way the bar fills up.
Turns the node into a radial bar. The fills counterclockwise. See , and to control the way the bar fills up.
The fills from the center, expanding both towards the left and the right.
The fills from the center, expanding both towards the top and the bottom.
Turns the node into a radial bar. The fills radially from the center, expanding both clockwise and counterclockwise. See , and to control the way the bar fills up.
that draws under the progress bar. The bar's background.
that draws over the progress bar. Use it to add highlights or an upper-frame that hides part of .
that clips based on the node's value and . As value increased, the texture fills up. It shows entirely when value reaches max_value. It doesn't show at all if value is equal to min_value.
The value property comes from . See , , .
The offset of . Useful for and with fancy borders, to avoid transparent margins in your progress texture.
The fill direction. See for possible values.
Multiplies the color of the bar's texture_under texture.
Multiplies the color of the bar's texture_over texture. The effect is similar to , except it only affects this specific texture instead of the entire node.
Multiplies the color of the bar's texture_progress texture.
Starting angle for the fill of if is or . When the node's value is equal to its min_value, the texture doesn't show up at all. When the value increases, the texture fills and tends towards .
Upper limit for the fill of if is or . When the node's value is equal to its max_value, the texture fills up to this angle.
See , .
Offsets if is or .
If true, Godot treats the bar's textures like in . Use the stretch_margin_* properties like to set up the nine patch's 3×3 grid. When using a radial , this setting will enable stretching.
The width of the 9-patch's left column.
The height of the 9-patch's top row.
The width of the 9-patch's right column.
The height of the 9-patch's bottom row. A margin of 16 means the 9-slice's bottom corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
Used to draw icons and sprites in a user interface. The texture's placement can be controlled with the property. It can scale, tile, or stay centered inside its bounding rectangle.
Note: You should enable when using a TextureRect to display a . Alternatively, you can enable on the Viewport. Otherwise, the image will appear upside down.
Scale to fit the node's bounding rectangle, only if expand is true. Default stretch_mode, for backwards compatibility. Until you set expand to true, the texture will behave like .
Scale to fit the node's bounding rectangle.
Tile inside the node's bounding rectangle.
The texture keeps its original size and stays in the bounding rectangle's top-left corner.
The texture keeps its original size and stays centered in the node's bounding rectangle.
Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.
Scale the texture to fit the node's bounding rectangle, center it and maintain its aspect ratio.
Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.
The node's resource.
If true, the texture scales to fit its bounding rectangle.
Controls the texture's behavior when resizing the node's bounding rectangle. See .
If true, texture is flipped horizontally.
If true, texture is flipped vertically.
A theme for skinning controls. Controls can be skinned individually, but for complex applications, it's more practical to just create a global theme that defines everything. This theme can be applied to any ; the Control and its children will automatically use it.
Theme resources can alternatively be loaded by writing them in a .theme file, see the documentation for more information.
Theme's item type.
Theme's constant item type.
Theme's item type.
Theme's icon item type.
Theme's item type.
Maximum value for the DataType enum.
The default font of this resource. Used as a fallback value for font items defined in this theme, but having invalid values. If this value is also invalid, the global default value is used.
Use to check if this value is valid.
Sets the theme's icon to texture at name in theme_type.
Creates theme_type if the theme does not have it.
Returns the icon at name if the theme has theme_type.
Returns true if icon with name is in theme_type.
Returns false if the theme does not have theme_type.
Renames the icon at old_name to name if the theme has theme_type. If name is already taken, this method fails.
Clears the icon at name if the theme has theme_type.
Returns all the icons as a filled with each 's name, for use in , if the theme has theme_type.
Returns all the icon types as a filled with unique type names, for use in and/or .
Sets theme's to stylebox at name in theme_type.
Creates theme_type if the theme does not have it.
Returns the at name if the theme has theme_type.
Valid names may be found using . Valid theme_types may be found using .
Returns true if with name is in theme_type.
Returns false if the theme does not have theme_type.
Renames at old_name to name if the theme has theme_type. If name is already taken, this method fails.
Clears at name if the theme has theme_type.
Returns all the s as a filled with each 's name, for use in , if the theme has theme_type.
Valid theme_types may be found using .
Returns all the types as a filled with unique type names, for use in and/or .
Sets the theme's to font at name in theme_type.
Creates theme_type if the theme does not have it.
Returns the at name if the theme has theme_type. If such item does not exist and is set on the theme, the default font will be returned.
Returns true if with name is in theme_type.
Returns false if the theme does not have theme_type.
Renames the at old_name to name if the theme has theme_type. If name is already taken, this method fails.
Clears the at name if the theme has theme_type.
Returns all the s as a filled with each 's name, for use in , if the theme has theme_type.
Returns all the types as a filled with unique type names, for use in and/or .
Sets the theme's to color at name in theme_type.
Creates theme_type if the theme does not have it.
Returns the at name if the theme has theme_type.
Returns true if with name is in theme_type.
Returns false if the theme does not have theme_type.
Renames the at old_name to name if the theme has theme_type. If name is already taken, this method fails.
Clears the at name if the theme has theme_type.
Returns all the s as a filled with each 's name, for use in , if the theme has theme_type.
Returns all the types as a filled with unique type names, for use in and/or .
Sets the theme's constant to constant at name in theme_type.
Creates theme_type if the theme does not have it.
Returns the constant at name if the theme has theme_type.
Returns true if constant with name is in theme_type.
Returns false if the theme does not have theme_type.
Renames the constant at old_name to name if the theme has theme_type. If name is already taken, this method fails.
Clears the constant at name if the theme has theme_type.
Returns all the constants as a filled with each constant's name, for use in , if the theme has theme_type.
Returns all the constant types as a filled with unique type names, for use in and/or .
Returns true if this theme has a valid value.
Sets the theme item of data_type to value at name in theme_type.
Does nothing if the value type does not match data_type.
Creates theme_type if the theme does not have it.
Returns the theme item of data_type at name if the theme has theme_type.
Valid names may be found using or a data type specific method. Valid theme_types may be found using or a data type specific method.
Returns true if a theme item of data_type with name is in theme_type.
Returns false if the theme does not have theme_type.
Renames the theme item of data_type at old_name to name if the theme has theme_type. If name is already taken, this method fails.
Clears the theme item of data_type at name if the theme has theme_type.
Returns all the theme items of data_type as a filled with each theme items's name, for use in or a data type specific method, if the theme has theme_type.
Valid theme_types may be found using or a data type specific method.
Returns all the theme items of data_type types as a filled with unique type names, for use in , or data type specific methods.
Marks theme_type as a variation of base_type.
This adds theme_type as a suggested option for on a that is of the base_type class.
Variations can also be nested, i.e. base_type can be another variation. If a chain of variations ends with a base_type matching the class of the , the whole chain is going to be suggested as options.
Note: Suggestions only show up if this theme resource is set as the project default theme. See .
Returns true if theme_type is marked as a variation of base_type.
Unmarks theme_type as being a variation of another theme type. See .
Returns the name of the base theme type if theme_type is a valid variation type. Returns an empty string otherwise.
Returns a list of all type variations for the given base_type.
Adds an empty theme type for every valid data type.
Note: Empty types are not saved with the theme. This method only exists to perform in-memory changes to the resource. Use available set_* methods to add theme items.
Removes the theme type, gracefully discarding defined theme items. If the type is a variation, this information is also erased. If the type is a base for type variations, those variations lose their base.
Returns all the theme types as a filled with unique type names, for use in other get_* functions of this theme.
Note: theme_type has no effect and will be removed in future version.
Sets the theme's values to a copy of the default theme values.
Sets the theme's values to a copy of a given theme.
Adds missing and overrides existing definitions with values from the other .
Note: This modifies the current theme. If you want to merge two themes together without modifying either one, create a new empty theme and merge the other two into it one after another.
Clears all values on the theme.
Node for 2D tile-based maps. Tilemaps use a which contain a list of tiles (textures plus optional collision, navigation, and/or occluder shapes) which are used to create grid-based maps.
When doing physics queries against the tilemap, the cell coordinates are encoded as metadata for each detected collision shape returned by methods such as , , etc.
Returned when a cell doesn't exist.
Orthogonal orientation mode.
Isometric orientation mode.
Custom orientation mode.
Tile origin at its top-left corner.
Tile origin at its center.
Tile origin at its bottom-left corner.
Half offset on the X coordinate.
Half offset on the Y coordinate.
Half offset disabled.
Half offset on the X coordinate (negative).
Half offset on the Y coordinate (negative).
The TileMap orientation mode. See for possible values.
The assigned .
The TileMap's cell size.
The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size.
The custom to be applied to the TileMap's cells.
Amount to offset alternating tiles. See for possible values.
Position for tile origin. See for possible values.
If true, the TileMap's direct children will be drawn in order of their Y coordinate.
If true, collision shapes are visible in the editor. Doesn't affect collision shapes visibility at runtime. To show collision shapes at runtime, enable Visible Collision Shapes in the Debug menu instead.
If true, the compatibility with the tilemaps made in Godot 3.1 or earlier is maintained (textures move when the tile origin changes and rotate if the texture size is not homogeneous). This mode presents problems when doing flip_h, flip_v and transpose tile operations on non-homogeneous isometric tiles (e.g. 2:1), in which the texture could not coincide with the collision, thus it is not recommended for isometric or non-square tiles.
If false, the textures do not move when doing flip_h, flip_v operations if no offset is used, nor when changing the tile origin.
The compatibility mode doesn't work with the option, because displacing textures with the option or in irregular tiles is not relevant when centering those textures.
If true, the textures will be centered in the middle of each tile. This is useful for certain isometric or top-down modes when textures are made larger or smaller than the tiles (e.g. to avoid flickering on tile edges). The offset is still applied, but from the center of the tile. If used, is ignored.
If false, the texture position start in the top-left corner unless is enabled.
If true, the cell's UVs will be clipped.
If true, this tilemap's collision shape will be added to the collision shape of the parent. The parent has to be a .
If true, TileMap collisions will be handled as a kinematic body. If false, collisions will be handled as static body.
Friction value for static body collisions (see collision_use_kinematic).
Bounce value for static body collisions (see collision_use_kinematic).
The collision layer(s) for all colliders in the TileMap. See Collision layers and masks in the documentation for more information.
The collision mask(s) for all colliders in the TileMap. See Collision layers and masks in the documentation for more information.
If true, this TileMap bakes a navigation region.
The navigation layers the TileMap generates its navigation regions in.
The light mask assigned to all light occluders in the TileMap. The TileSet's light occluders will cast shadows only from Light2D(s) that have the same light mask(s).
Sets the given collision layer bit.
Returns true if the given collision layer bit is set.
Sets the given collision mask bit.
Returns true if the given collision mask bit is set.
Sets the tile index for the given cell.
An index of -1 clears the cell.
Optionally, the tile can also be flipped, transposed, or given autotile coordinates. The autotile coordinate refers to the column and row of the subtile.
Note: Data such as navigation polygons and collision shapes are not immediately updated for performance reasons.
If you need these to be immediately updated, you can call .
Overriding this method also overrides it internally, allowing custom logic to be implemented when tiles are placed/removed:
func set_cell(x, y, tile, flip_x=false, flip_y=false, transpose=false, autotile_coord=Vector2()):
# Write your custom logic here.
# To call the default method:
.set_cell(x, y, tile, flip_x, flip_y, transpose, autotile_coord)
If the parameter is null, then the default value is new Vector2(0, 0)
Sets the tile index for the cell given by a Vector2.
An index of -1 clears the cell.
Optionally, the tile can also be flipped, transposed, or given autotile coordinates. The autotile coordinate refers to the column and row of the subtile.
Note: Data such as navigation polygons and collision shapes are not immediately updated for performance reasons.
If you need these to be immediately updated, you can call .
If the parameter is null, then the default value is new Vector2(0, 0)
Returns the tile index of the given cell. If no tile exists in the cell, returns .
Returns the tile index of the cell given by a Vector2. If no tile exists in the cell, returns .
Returns true if the given cell is flipped in the X axis.
Returns true if the given cell is flipped in the Y axis.
Returns true if the given cell is transposed, i.e. the X and Y axes are swapped.
Returns the coordinate (subtile column and row) of the autotile variation in the tileset. Returns a zero vector if the cell doesn't have autotiling.
Clears cells that do not exist in the tileset.
Clears all cells.
Returns a array with the positions of all cells containing a tile from the tileset (i.e. a tile index different from -1).
Returns an array of all cells with the given tile index specified in id.
Returns a rectangle enclosing the used (non-empty) tiles of the map.
Returns the local position of the top left corner of the cell corresponding to the given tilemap (grid-based) coordinates.
To get the global position, use :
var local_position = my_tilemap.map_to_world(map_position)
var global_position = my_tilemap.to_global(local_position)
Optionally, the tilemap's half offset can be ignored.
Returns the tilemap (grid-based) coordinates corresponding to the given local position.
To use this with a global position, first determine the local position with :
var local_position = my_tilemap.to_local(global_position)
var map_position = my_tilemap.world_to_map(local_position)
Updates the tile map's quadrants, allowing things such as navigation and collision shapes to be immediately used if modified.
Applies autotiling rules to the cell (and its adjacent cells) referenced by its grid-based X and Y coordinates.
Applies autotiling rules to the cells in the given region (specified by grid-based X and Y coordinates).
Calling with invalid (or missing) parameters applies autotiling rules for the entire tilemap.
If the parameter is null, then the default value is new Vector2(0, 0)
If the parameter is null, then the default value is new Vector2(0, 0)
A TileSet is a library of tiles for a . It contains a list of tiles, each consisting of a sprite and optional collision shapes.
Tiles are referenced by a unique integer ID.
Determines when the auto-tiler should consider two different auto-tile IDs to be bound together.
Note: neighbor_id will be -1 () when checking a tile against an empty neighbor tile.
Creates a new tile with the given ID.
Clears all bitmask information of the autotile.
Sets the subtile that will be used as an icon in an atlas/autotile given its coordinates.
The subtile defined as the icon will be used as a fallback when the atlas/autotile's bitmask information is incomplete. It will also be used to represent it in the TileSet editor.
Returns the subtile that's being used as an icon in an atlas/autotile given its coordinates.
The subtile defined as the icon will be used as a fallback when the atlas/autotile's bitmask information is incomplete. It will also be used to represent it in the TileSet editor.
Sets the priority of the subtile from an autotile given its coordinates.
When more than one subtile has the same bitmask value, one of them will be picked randomly for drawing. Its priority will define how often it will be picked.
Returns the priority of the subtile from an autotile given its coordinates.
When more than one subtile has the same bitmask value, one of them will be picked randomly for drawing. Its priority will define how often it will be picked.
Sets the drawing index of the subtile from an atlas/autotile given its coordinates.
Returns the drawing index of the subtile from an atlas/autotile given its coordinates.
Sets the light occluder of the subtile from an atlas/autotile given its coordinates.
Returns the light occluder of the subtile from an atlas/autotile given its coordinates.
Sets the navigation polygon of the subtile from an atlas/autotile given its coordinates.
Returns the navigation polygon of the subtile from an atlas/autotile given its coordinates.
Sets the bitmask of the subtile from an autotile given its coordinates.
The value is the sum of the values in present in the subtile (e.g. a value of 5 means the bitmask has bindings in both the top left and top right).
Returns the bitmask of the subtile from an autotile given its coordinates.
The value is the sum of the values in present in the subtile (e.g. a value of 5 means the bitmask has bindings in both the top left and top right).
Sets the of the autotile.
Returns the of the autotile.
Sets the spacing between subtiles of the atlas/autotile.
Returns the spacing between subtiles of the atlas/autotile.
Sets the size of the subtiles in an atlas/autotile.
Returns the size of the subtiles in an atlas/autotile.
Sets the tile's name.
Returns the tile's name.
Sets the tile's texture.
Returns the tile's texture.
Sets the tile's normal map texture.
Note: Godot expects the normal map to use X+, Y-, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.
Returns the tile's normal map texture.
Sets the tile's material.
Returns the tile's material.
Sets the tile's modulation color.
Note: Modulation is performed by setting the tile's vertex color. To access this in a shader, use COLOR rather than MODULATE (which instead accesses the 's property).
Returns the tile's modulation color.
Sets the tile's texture offset.
Returns the texture offset of the tile.
Sets the tile's sub-region in the texture. This is common in texture atlases.
Returns the tile sub-region in the texture.
Sets a shape for the tile, enabling collision.
Returns a tile's given shape.
Sets the offset of a tile's shape.
Returns the offset of a tile's shape.
Sets a on a tile's shape.
Returns the of a tile's shape.
Enables one-way collision on a tile's shape.
Returns the one-way collision value of a tile's shape.
Adds a shape to the tile.
If the parameter is null, then the default value is new Vector2(0, 0)
Returns the number of shapes assigned to a tile.
Sets an array of shapes for the tile, enabling collision.
Returns an array of dictionaries describing the tile's shapes.
Dictionary structure in the array returned by this method:
{
"autotile_coord": Vector2,
"one_way": bool,
"one_way_margin": int,
"shape": CollisionShape2D,
"shape_transform": Transform2D,
}
Sets the tile's .
Returns the tile's .
Sets the tile's navigation polygon.
Returns the navigation polygon of the tile.
Sets an offset for the tile's navigation polygon.
Returns the offset of the tile's navigation polygon.
Sets a light occluder for the tile.
Returns the tile's light occluder.
Sets an offset for the tile's light occluder.
Returns the offset of the tile's light occluder.
Sets the tile's drawing index.
Returns the tile's Z index (drawing layer).
Removes the given tile ID.
Clears all tiles.
Returns the ID following the last currently used ID, useful when creating a new tile.
Returns the first tile matching the given name.
Returns an array of all currently used tile IDs.
The Time singleton allows converting time between various formats and also getting time information from the system.
This class conforms with as many of the ISO 8601 standards as possible. All dates follow the Proleptic Gregorian calendar. As such, the day before 1582-10-15 is 1582-10-14, not 1582-10-04. The year before 1 AD (aka 1 BC) is number 0, with the year before that (2 BC) being -1, etc.
Conversion methods assume "the same timezone", and do not handle timezone conversions or DST automatically. Leap seconds are also not handled, they must be done manually if desired. Suffixes such as "Z" are not handled, you need to strip them away manually.
When getting time information from the system, the time can either be in the local timezone or UTC depending on the utc parameter. However, the method always returns the time in UTC.
Important: The _from_system methods use the system clock that the user can manually set. Never use this method for precise time calculation since its results are subject to automatic adjustments by the user or the operating system. Always use or for precise time calculation instead, since they are guaranteed to be monotonic (i.e. never decrease).
The month of January, represented numerically as 01.
The month of February, represented numerically as 02.
The month of March, represented numerically as 03.
The month of April, represented numerically as 04.
The month of May, represented numerically as 05.
The month of June, represented numerically as 06.
The month of July, represented numerically as 07.
The month of August, represented numerically as 08.
The month of September, represented numerically as 09.
The month of October, represented numerically as 10.
The month of November, represented numerically as 11.
The month of December, represented numerically as 12.
The day of the week Sunday, represented numerically as 0.
The day of the week Monday, represented numerically as 1.
The day of the week Tuesday, represented numerically as 2.
The day of the week Wednesday, represented numerically as 3.
The day of the week Thursday, represented numerically as 4.
The day of the week Friday, represented numerically as 5.
The day of the week Saturday, represented numerically as 6.
Converts the given Unix timestamp to a dictionary of keys: year, month, day, and weekday.
The returned Dictionary's values will be the same as the if the Unix timestamp is the current time, with the exception of Daylight Savings Time as it cannot be determined from the epoch.
Converts the given Unix timestamp to a dictionary of keys: year, month, day, and weekday.
Converts the given time to a dictionary of keys: hour, minute, and second.
Converts the given Unix timestamp to an ISO 8601 date and time string (YYYY-MM-DDTHH:MM:SS).
If use_space is true, use a space instead of the letter T in the middle.
Converts the given Unix timestamp to an ISO 8601 date string (YYYY-MM-DD).
Converts the given Unix timestamp to an ISO 8601 time string (HH:MM:SS).
Converts the given ISO 8601 date and time string (YYYY-MM-DDTHH:MM:SS) to a dictionary of keys: year, month, day, weekday, hour, minute, and second.
If weekday is false, then the weekday entry is excluded (the calculation is relatively expensive).
Note: Any decimal fraction in the time string will be ignored silently.
Converts the given dictionary of keys to an ISO 8601 date and time string (YYYY-MM-DDTHH:MM:SS).
The given dictionary can be populated with the following keys: year, month, day, hour, minute, and second. Any other entries (including dst) are ignored.
If the dictionary is empty, 0 is returned. If some keys are omitted, they default to the equivalent values for the Unix epoch timestamp 0 (1970-01-01 at 00:00:00).
If use_space is true, use a space instead of the letter T in the middle.
Converts a dictionary of time values to a Unix timestamp.
The given dictionary can be populated with the following keys: year, month, day, hour, minute, and second. Any other entries (including dst) are ignored.
If the dictionary is empty, 0 is returned. If some keys are omitted, they default to the equivalent values for the Unix epoch timestamp 0 (1970-01-01 at 00:00:00).
You can pass the output from directly into this function and get the same as what was put in.
Note: Unix timestamps are often in UTC. This method does not do any timezone conversion, so the timestamp will be in the same timezone as the given datetime dictionary.
Converts the given ISO 8601 date and/or time string to a Unix timestamp. The string can contain a date only, a time only, or both.
Note: Unix timestamps are often in UTC. This method does not do any timezone conversion, so the timestamp will be in the same timezone as the given datetime string.
Note: Any decimal fraction in the time string will be ignored silently.
Converts the given timezone offset in minutes to a timezone offset string. For example, -480 returns "-08:00", 345 returns "+05:45", and 0 returns "+00:00".
Returns the current date as a dictionary of keys: year, month, day, weekday, hour, minute, and second.
Returns the current date as a dictionary of keys: year, month, day, weekday, and dst (Daylight Savings Time).
The returned values are in the system's local time when utc is false, otherwise they are in UTC.
Returns the current time as a dictionary of keys: hour, minute, and second.
The returned values are in the system's local time when utc is false, otherwise they are in UTC.
Returns the current date and time as an ISO 8601 date and time string (YYYY-MM-DDTHH:MM:SS).
The returned values are in the system's local time when utc is false, otherwise they are in UTC.
If use_space is true, use a space instead of the letter T in the middle.
Returns the current date as an ISO 8601 date string (YYYY-MM-DD).
The returned values are in the system's local time when utc is false, otherwise they are in UTC.
Returns the current time as an ISO 8601 time string (HH:MM:SS).
The returned values are in the system's local time when utc is false, otherwise they are in UTC.
Returns the current time zone as a dictionary of keys: bias and name. The bias value is the offset from UTC in minutes, since not all time zones are multiples of an hour from UTC.
Returns the current Unix timestamp in seconds based on the system time in UTC. This method is implemented by the operating system and always returns the time in UTC.
Note: Unlike other methods that use integer timestamps, this method returns the timestamp as a for sub-second precision.
Returns the amount of time passed in milliseconds since the engine started.
Will always be positive or 0 and uses a 64-bit value (it will wrap after roughly 500 million years).
Returns the amount of time passed in microseconds since the engine started.
Will always be positive or 0 and uses a 64-bit value (it will wrap after roughly half a million years).
Counts down a specified interval and emits a signal on reaching 0. Can be set to repeat or "one-shot" mode.
Note: To create a one-shot timer without instantiating a node, use .
Update the timer during the physics step at each frame (fixed framerate processing).
Update the timer during the idle time at each frame.
Processing mode. See .
The wait time in seconds.
Note: Timers can only emit once per rendered frame at most (or once per physics frame if is ). This means very low wait times (lower than 0.05 seconds) will behave in significantly different ways depending on the rendered framerate. For very low wait times, it is recommended to use a process loop in a script instead of using a Timer node.
If true, the timer will stop when reaching 0. If false, it will restart.
If true, the timer will automatically start when entering the scene tree.
Note: This property is automatically set to false after the timer enters the scene tree and starts.
If true, the timer is paused and will not process until it is unpaused again, even if is called.
The timer's remaining time in seconds. Returns 0 if the timer is inactive.
Note: You cannot set this value. To change the timer's remaining time, use .
Starts the timer. Sets wait_time to time_sec if time_sec > 0. This also resets the remaining time to wait_time.
Note: This method will not resume a paused timer. See .
Stops the timer.
Returns true if the timer is stopped.
This is a helper class to generate a flat (see ), creating a is equivalent to:
var btn = Button.new()
btn.flat = true
TouchScreenButton allows you to create on-screen buttons for touch devices. It's intended for gameplay use, such as a unit you have to touch to move. Unlike , TouchScreenButton supports multitouch out of the box. Several TouchScreenButtons can be pressed at the same time with touch input.
This node inherits from . Unlike with nodes, you cannot set anchors on it. If you want to create menus or user interfaces, you may want to use nodes instead. To make button nodes react to touch events, you can enable the Emulate Mouse option in the Project Settings.
You can configure TouchScreenButton to be visible only on touch devices, helping you develop your game both for desktop and mobile devices.
Always visible.
Visible on touch screens only.
The button's texture for the normal state.
The button's texture for the pressed state.
The button's bitmask.
The button's shape.
If true, the button's shape is centered in the provided texture. If no texture is used, this property has no effect.
If true, the button's shape is visible.
If true, the pressed and released signals are emitted whenever a pressed finger goes in and out of the button, even if the pressure started outside the active area of the button.
Note: This is a "pass-by" (not "bypass") press mode.
The button's action. Actions can be handled with .
The button's visibility mode. See for possible values.
Returns true if this button is currently pressed.
Translations are resources that can be loaded and unloaded on demand. They map a string to another string.
The locale of the translation.
Virtual method to override .
Adds a message if nonexistent, followed by its translation.
Returns a message's translation.
Erases a message.
Returns all the messages (keys).
Returns the number of existing messages.
Server that manages all translations. Translations can be set to it and removed from it.
Sets the locale of the project. The locale string will be standardized to match known locales (e.g. en-US would be matched to en_US).
If translations have been loaded beforehand for the new locale, they will be applied.
Returns the current locale of the project.
See also and to query the locale of the user system.
Returns a locale's language and its variant (e.g. "en_US" would return "English (United States)").
Returns the current locale's translation for the given message (key).
Adds a resource.
Removes the given translation from the server.
Clears the server from all translations.
Returns an array of all loaded locales of the project.
This shows a tree of items that can be selected, expanded and collapsed. The tree can have multiple columns with custom controls like text editing, buttons and popups. It can be useful for structured displays and interactions.
Trees are built via code, using objects to create the structure. They have a single root but multiple roots can be simulated if a dummy hidden root is added.
func _ready():
var tree = Tree.new()
var root = tree.create_item()
tree.set_hide_root(true)
var child1 = tree.create_item(root)
var child2 = tree.create_item(root)
var subchild1 = tree.create_item(child1)
subchild1.set_text(0, "Subchild1")
To iterate over all the objects in a object, use and after getting the root through . You can use on a to remove it from the .
Incremental search: Like and , supports searching within the list while the control is focused. Press a key that matches the first letter of an item's name to select the first item starting with the given letter. After that point, there are two ways to perform incremental search: 1) Press the same key again before the timeout duration to select the next item starting with the same letter. 2) Press letter keys that match the rest of the word before the timeout duration to match to select the item in question directly. Both of these actions will be reset to the beginning of the list if the timeout duration has passed since the last keystroke was registered. You can adjust the timeout duration by changing .
Allows selection of a single cell at a time. From the perspective of items, only a single item is allowed to be selected. And there is only one column selected in the selected item.
The focus cursor is always hidden in this mode, but it is positioned at the current selection, making the currently selected item the currently focused item.
Allows selection of a single row at a time. From the perspective of items, only a single items is allowed to be selected. And all the columns are selected in the selected item.
The focus cursor is always hidden in this mode, but it is positioned at the first column of the current selection, making the currently selected item the currently focused item.
Allows selection of multiple cells at the same time. From the perspective of items, multiple items are allowed to be selected. And there can be multiple columns selected in each selected item.
The focus cursor is visible in this mode, the item or column under the cursor is not necessarily selected.
Disables all drop sections, but still allows to detect the "on item" drop section by .
Note: This is the default flag, it has no effect when combined with other flags.
Enables the "on item" drop section. This drop section covers the entire item.
When combined with , this drop section halves the height and stays centered vertically.
Enables "above item" and "below item" drop sections. The "above item" drop section covers the top half of the item, and the "below item" drop section covers the bottom half.
When combined with , these drop sections halves the height and stays on top / bottom accordingly.
The number of columns.
If true, column titles are visible.
If true, the currently selected cell may be selected again.
If true, a right mouse button click can select items.
If true, the folding arrow is hidden.
If true, the tree's root is hidden.
The drop mode as an OR combination of flags. See constants. Once dropping is done, reverts to . Setting this during is recommended.
This controls the drop sections, i.e. the decision and drawing of possible drop locations based on the mouse position.
Allows single or multiple selection. See the constants.
Clears the tree. This removes all items.
Creates an item in the tree and adds it as a child of parent, which can be either a valid or null.
If parent is null, the root item will be the parent, or the new item will be the root itself if the tree is empty.
The new item will be the idxth child of parent, or it will be the last child if there are not enough siblings.
Returns the tree's root item, or null if the tree is empty.
Sets the minimum width of a column. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to .
If true, the column will have the "Expand" flag of . Columns that have the "Expand" flag will use their "min_width" in a similar fashion to .
Returns the column's width in pixels.
Returns the next selected after the given one, or null if the end is reached.
If from is null, this returns the first selected item.
Returns the currently focused item, or null if no item is focused.
In and modes, the focused item is same as the selected item. In mode, the focused item is the item under the focus cursor, not necessarily selected.
To get the currently selected item(s), use .
Returns the currently focused column, or -1 if no column is focused.
In mode, the focused column is the selected column. In mode, the focused column is always 0 if any item is selected. In mode, the focused column is the column under the focus cursor, and there are not necessarily any column selected.
To tell whether a column of an item is selected, use .
Returns the last pressed button's index.
Returns the currently edited item. Can be used with item_edited to get the item that was modified.
func _ready():
$Tree.connect("item_edited", self, "on_Tree_item_edited")
func on_Tree_item_edited():
print($Tree.get_edited()) # This item just got edited (e.g. checked).
Returns the column for the currently edited item.
Edits the selected tree item as if it was clicked. The item must be set editable with . Returns true if the item could be edited. Fails if no item is selected.
Returns the rectangle for custom popups. Helper to create custom cell controls that display a popup. See .
Returns the rectangle area for the specified . If column is specified, only get the position and size of that column, otherwise get the rectangle containing all columns.
Returns the tree item at the specified position (relative to the tree origin position).
Returns the column index at position, or -1 if no item is there.
Returns the drop section at position, or -100 if no item is there.
Values -1, 0, or 1 will be returned for the "above item", "on item", and "below item" drop sections, respectively. See for a description of each drop section.
To get the item which the returned drop section is relative to, use .
Returns the button id at position, or -1 if no button is there.
Makes the currently focused cell visible.
This will scroll the tree if necessary. In mode, this will not do horizontal scrolling, as all the cells in the selected row is focused logically.
Note: Despite the name of this method, the focus cursor itself is only visible in mode.
Sets the title of a column.
Returns the column's title.
Returns the current scrolling position.
Causes the to jump to the specified .
Control for a single item inside a . May have child s and be styled as well as contain buttons.
You can remove a by using .
Cell contains a string.
Cell contains a checkbox.
Cell contains a range.
Cell contains an icon.
Align text to the left. See set_text_align().
Center text. See set_text_align().
Align text to the right. See set_text_align().
If true, the TreeItem is collapsed.
If true, folding is disabled for this TreeItem.
The custom minimum height.
Sets the given column's cell mode to mode. See constants.
Returns the column's cell mode.
If true, the column column is checked.
Returns true if the given column is checked.
Sets the given column's text value.
Returns the given column's text.
Sets a string to be shown after a column's value (for example, a unit abbreviation).
Gets the suffix string shown after the column value.
Sets the given column's icon .
Returns the given column's icon . Error if no icon is set.
Sets the given column's icon's texture region.
Returns the icon region as .
Sets the given column's icon's maximum width.
Returns the column's icon's maximum width.
Modulates the given column's icon with modulate.
Returns the modulating the column's icon.
Sets the value of a column.
Returns the value of a column.
Sets the range of accepted values for a column. The column must be in the mode.
If expr is true, the edit mode slider will use an exponential scale as with .
Returns a dictionary containing the range parameters for a given column. The keys are "min", "max", "step", and "expr".
Sets the metadata value for the given column, which can be retrieved later using . This can be used, for example, to store a reference to the original data.
Returns the metadata value that was set for the given column using .
Sets the given column's custom draw callback to callback method on object.
The callback should accept two arguments: the that is drawn and its position and size as a .
Returns the next sibling TreeItem in the tree or a null object if there is none.
Returns the previous sibling TreeItem in the tree or a null object if there is none.
Returns the parent TreeItem or a null object if there is none.
Returns the TreeItem's first child item or a null object if there is none.
Returns the next visible sibling TreeItem in the tree or a null object if there is none.
If wrap is enabled, the method will wrap around to the first visible element in the tree when called on the last visible element, otherwise it returns null.
Returns the previous visible sibling TreeItem in the tree or a null object if there is none.
If wrap is enabled, the method will wrap around to the last visible element in the tree when called on the first visible element, otherwise it returns null.
Removes the given child and all its children from the . Note that it doesn't free the item from memory, so it can be reused later. To completely remove a use .
If true, the given column is selectable.
Returns true if column column is selectable.
Returns true if column column is selected.
Selects the column column.
Deselects the given column.
If true, column column is editable.
Returns true if column column is editable.
Sets the given column's custom color.
Resets the color for the given column to default.
Returns the custom color of column column.
Sets the given column's custom background color and whether to just use it as an outline.
Resets the background color for the given column to default.
Returns the custom background color of column column.
Adds a button with button at column column. The id is used to identify the button. If not specified, the next available index is used, which may be retrieved by calling immediately before this method. Optionally, the button can be disabled and have a tooltip.
Returns the number of buttons in column column.
Returns the tooltip string for the button at index button_idx in column column.
Returns the id for the button at index button_idx in column column.
Returns the button index if there is a button with id id in column column, otherwise returns -1.
Returns the of the button at index button_idx in column column.
Sets the given column's button at index button_idx to button.
Removes the button at index button_idx in column column.
If true, disables the button at index button_idx in column column.
Returns true if the button at index button_idx for the given column is disabled.
If true, column column is expanded to the right.
Returns true if expand_right is set.
Sets the given column's tooltip text.
Returns the given column's tooltip.
Sets the given column's text alignment. See for possible values.
Returns the given column's text alignment.
Moves this TreeItem to the top in the hierarchy.
Moves this TreeItem to the bottom in the hierarchy.
Calls the method on the actual TreeItem and its children recursively. Pass parameters as a comma separated list.
Mesh type used internally for collision calculations.
Tweens are useful for animations requiring a numerical property to be interpolated over a range of values. The name tween comes from in-betweening, an animation technique where you specify keyframes and the computer interpolates the frames that appear between them.
is more suited than for animations where you don't know the final values in advance. For example, interpolating a dynamically-chosen camera zoom value is best done with a node; it would be difficult to do the same thing with an node.
Here is a brief usage example that makes a 2D node move smoothly between two positions:
var tween = get_node("Tween")
tween.interpolate_property($Node2D, "position",
Vector2(0, 0), Vector2(100, 100), 1,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
Many methods require a property name, such as "position" above. You can find the correct property name by hovering over the property in the Inspector. You can also provide the components of a property directly by using "property:component" (e.g. position:x), where it would only apply to that particular component.
Many of the methods accept trans_type and ease_type. The first accepts an constant, and refers to the way the timing of the animation is handled (see easings.net for some examples). The second accepts an constant, and controls where the trans_type is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different constants with , and use the one that looks best.
Tween easing and transition types cheatsheet
Note: Tween methods will return false if the requested operation cannot be completed.
Note: For an alternative method of tweening, that doesn't require using nodes, see .
The animation is interpolated linearly.
The animation is interpolated using a sine function.
The animation is interpolated with a quintic (to the power of 5) function.
The animation is interpolated with a quartic (to the power of 4) function.
The animation is interpolated with a quadratic (to the power of 2) function.
The animation is interpolated with an exponential (to the power of x) function.
The animation is interpolated with elasticity, wiggling around the edges.
The animation is interpolated with a cubic (to the power of 3) function.
The animation is interpolated with a function using square roots.
The animation is interpolated by bouncing at the end.
The animation is interpolated backing out at ends.
The tween updates with the _physics_process callback.
The tween updates with the _process callback.
The interpolation starts slowly and speeds up towards the end.
The interpolation starts quickly and slows down towards the end.
A combination of and . The interpolation is slowest at both ends.
A combination of and . The interpolation is fastest at both ends.
If true, the tween loops.
The tween's animation process thread. See .
The tween's speed multiplier. For example, set it to 1.0 for normal speed, 2.0 for two times normal speed, or 0.5 for half of the normal speed. A value of 0 pauses the animation, but see also or for this.
Returns true if any tweens are currently running.
Note: This method doesn't consider tweens that have ended.
Activates/deactivates the tween. See also and .
Starts the tween. You can define animations both before and after this.
Resets a tween to its initial value (the one given, not the one before the tween), given its object and property/method pair. By default, all tweens are reset, unless key is specified.
Resets all tweens to their initial values (the ones given, not those before the tween).
Stops a tween, given its object and property/method pair. By default, all tweens are stopped, unless key is specified.
Stops animating all tweens.
Continues animating a stopped tween, given its object and property/method pair. By default, all tweens are resumed, unless key is specified.
Continues animating all stopped tweens.
Stops animation and removes a tween, given its object and property/method pair. By default, all tweens are removed, unless key is specified.
Stops animation and removes all tweens.
Sets the interpolation to the given time in seconds.
Returns the current time of the tween.
Returns the total time needed for all tweens to end. If you have two tweens, one lasting 10 seconds and the other 20 seconds, it would return 20 seconds, as by that time all tweens would have finished.
Animates property of object from initial_val to final_val for duration seconds, delay seconds later. Setting the initial value to null uses the current value of the property.
Use for trans_type and for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.
Animates method of object from initial_val to final_val for duration seconds, delay seconds later. Methods are called with consecutive values.
Use for trans_type and for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.
Calls callback of object after duration. arg1-arg5 are arguments to be passed to the callback.
Calls callback of object after duration on the main thread (similar to ). arg1-arg5 are arguments to be passed to the callback.
Follows property of object and applies it on target_property of target, beginning from initial_val for duration seconds, delay seconds later.
Use for trans_type and for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.
Follows method of object and applies the returned value on target_method of target, beginning from initial_val for duration seconds, delay later. Methods are called with consecutive values.
Use for trans_type and for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.
Animates property of object from the current value of the initial_val property of initial to final_val for duration seconds, delay seconds later.
Use for trans_type and for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.
Animates method of object from the value returned by initial_method to final_val for duration seconds, delay seconds later. Methods are animated by calling them with consecutive values.
Use for trans_type and for ease_type parameters. These values control the timing and direction of the interpolation. See the class description for more information.
Tweeners are objects that perform a specific animating task, e.g. interpolating a property or calling a method at a given time. A can't be created manually, you need to use a dedicated method from .
A simple server that opens a UDP socket and returns connected upon receiving new packets. See also .
After starting the server (), you will need to it at regular intervals (e.g. inside ) for it to process new packets, delivering them to the appropriate , and taking new connections.
Below a small example of how it can be used:
# server.gd
extends Node
var server := UDPServer.new()
var peers = []
func _ready():
server.listen(4242)
func _process(delta):
server.poll() # Important!
if server.is_connection_available():
var peer : PacketPeerUDP = server.take_connection()
var pkt = peer.get_packet()
print("Accepted peer: %s:%s" % [peer.get_packet_ip(), peer.get_packet_port()])
print("Received data: %s" % [pkt.get_string_from_utf8()])
# Reply so it knows we received the message.
peer.put_packet(pkt)
# Keep a reference so we can keep contacting the remote peer.
peers.append(peer)
for i in range(0, peers.size()):
pass # Do something with the connected peers.
# client.gd
extends Node
var udp := PacketPeerUDP.new()
var connected = false
func _ready():
udp.connect_to_host("127.0.0.1", 4242)
func _process(delta):
if !connected:
# Try to contact server
udp.put_packet("The answer is... 42!".to_utf8())
if udp.get_available_packet_count() > 0:
print("Connected: %s" % udp.get_packet().get_string_from_utf8())
connected = true
Define the maximum number of pending connections, during , any new pending connection exceeding that value will be automatically dropped. Setting this value to 0 effectively prevents any new pending connection to be accepted (e.g. when all your players have connected).
Starts the server by opening a UDP socket listening on the given port. You can optionally specify a bind_address to only listen for packets sent to that address. See also .
Call this method at regular intervals (e.g. inside ) to process new packets. And packet from known address/port pair will be delivered to the appropriate , any packet received from an unknown address/port pair will be added as a pending connection (see , ). The maximum number of pending connection is defined via .
Returns true if a packet with a new address/port combination was received on the socket.
Returns true if the socket is open and listening on a port.
Returns the first pending connection (connected to the appropriate address/port). Will return null if no new connection is available. See also , .
Stops the server, closing the UDP socket if open. Will close all connected accepted via (remote peers will not be notified).
This class can be used to discover compatible s on the local network and execute commands on them, like managing port mappings (for port forwarding/NAT traversal) and querying the local and remote network IP address. Note that methods on this class are synchronous and block the calling thread.
To forward a specific port (here 7777, note both and can return errors that should be checked):
var upnp = UPNP.new()
upnp.discover()
upnp.add_port_mapping(7777)
To close a specific port (e.g. after you have finished using it):
upnp.delete_port_mapping(port)
Note: UPnP discovery blocks the current thread. To perform discovery without blocking the main thread, use s like this:
# Emitted when UPnP port mapping setup is completed (regardless of success or failure).
signal upnp_completed(error)
# Replace this with your own server port number between 1024 and 65535.
const SERVER_PORT = 3928
var thread = null
func _upnp_setup(server_port):
# UPNP queries take some time.
var upnp = UPNP.new()
var err = upnp.discover()
if err != OK:
push_error(str(err))
emit_signal("upnp_completed", err)
return
if upnp.get_gateway() and upnp.get_gateway().is_valid_gateway():
upnp.add_port_mapping(server_port, server_port, ProjectSettings.get_setting("application/config/name"), "UDP")
upnp.add_port_mapping(server_port, server_port, ProjectSettings.get_setting("application/config/name"), "TCP")
emit_signal("upnp_completed", OK)
func _ready():
thread = Thread.new()
thread.start(self, "_upnp_setup", SERVER_PORT)
func _exit_tree():
# Wait for thread finish here to handle game exit while the thread is running.
thread.wait_to_finish()
Terminology: In the context of UPnP networking, "gateway" (or "internet gateway device", short IGD) refers to network devices that allow computers in the local network to access the internet ("wide area network", WAN). These gateways are often also called "routers".
Pitfalls:
- As explained above, these calls are blocking and shouldn't be run on the main thread, especially as they can block for multiple seconds at a time. Use threading!
- Networking is physical and messy. Packets get lost in transit or get filtered, addresses, free ports and assigned mappings change, and devices may leave or join the network at any time. Be mindful of this, be diligent when checking and handling errors, and handle these gracefully if you can: add clear error UI, timeouts and re-try handling.
- Port mappings may change (and be removed) at any time, and the remote/external IP address of the gateway can change likewise. You should consider re-querying the external IP and try to update/refresh the port mapping periodically (for example, every 5 minutes and on networking failures).
- Not all devices support UPnP, and some users disable UPnP support. You need to handle this (e.g. documenting and requiring the user to manually forward ports, or adding alternative methods of NAT traversal, like a relay/mirror server, or NAT hole punching, STUN/TURN, etc.).
- Consider what happens on mapping conflicts. Maybe multiple users on the same network would like to play your game at the same time, or maybe another application uses the same port. Make the port configurable, and optimally choose a port automatically (re-trying with a different port on failure).
Further reading: If you want to know more about UPnP (and the Internet Gateway Device (IGD) and Port Control Protocol (PCP) specifically), Wikipedia is a good first stop, the specification can be found at the Open Connectivity Foundation and Godot's implementation is based on the MiniUPnP client.
UPNP command or discovery was successful.
Not authorized to use the command on the . May be returned when the user disabled UPNP on their router.
No port mapping was found for the given port, protocol combination on the given .
Inconsistent parameters.
No such entry in array. May be returned if a given port, protocol combination is not found on an .
The action failed.
The does not allow wildcard values for the source IP address.
The does not allow wildcard values for the external port.
The does not allow wildcard values for the internal port.
The remote host value must be a wildcard.
The external port value must be a wildcard.
No port maps are available. May also be returned if port mapping functionality is not available.
Conflict with other mechanism. May be returned instead of if a port mapping conflicts with an existing one.
Conflict with an existing port mapping.
External and internal port values must be the same.
Only permanent leases are supported. Do not use the duration parameter when adding port mappings.
Invalid gateway.
Invalid port.
Invalid protocol.
Invalid duration.
Invalid arguments.
Invalid response.
Invalid parameter.
HTTP error.
Socket error.
Error allocating memory.
No gateway available. You may need to call first, or discovery didn't detect any valid IGDs (InternetGatewayDevices).
No devices available. You may need to call first, or discovery didn't detect any valid s.
Unknown error.
Multicast interface to use for discovery. Uses the default multicast interface if empty.
If 0, the local port to use for discovery is chosen automatically by the system. If 1, discovery will be done from the source port 1900 (same as destination port). Otherwise, the value will be used as the port.
If true, IPv6 is used for discovery.
Returns the number of discovered s.
Returns the at the given index.
Adds the given to the list of discovered devices.
Sets the device at index from the list of discovered devices to device.
Removes the device at index from the list of discovered devices.
Clears the list of discovered devices.
Returns the default gateway. That is the first discovered that is also a valid IGD (InternetGatewayDevice).
Discovers local s. Clears the list of previously discovered devices.
Filters for IGD (InternetGatewayDevice) type devices by default, as those manage port forwarding. timeout is the time to wait for responses in milliseconds. ttl is the time-to-live; only touch this if you know what you're doing.
See for possible return values.
Returns the external address of the default gateway (see ) as string. Returns an empty string on error.
Adds a mapping to forward the external port (between 1 and 65535, although recommended to use port 1024 or above) on the default gateway (see ) to the internal_port on the local machine for the given protocol proto (either TCP or UDP, with UDP being the default). If a port mapping for the given port and protocol combination already exists on that gateway device, this method tries to overwrite it. If that is not desired, you can retrieve the gateway manually with and call on it, if any. Note that forwarding a well-known port (below 1024) with UPnP may fail depending on the device.
Depending on the gateway device, if a mapping for that port already exists, it will either be updated or it will refuse this command due to that conflict, especially if the existing mapping for that port wasn't created via UPnP or points to a different network address (or device) than this one.
If internal_port is 0 (the default), the same port number is used for both the external and the internal port (the port value).
The description (desc) is shown in some routers management UIs and can be used to point out which application added the mapping.
The mapping's lease duration can be limited by specifying a duration in seconds. The default of 0 means no duration, i.e. a permanent lease and notably some devices only support these permanent leases. Note that whether permanent or not, this is only a request and the gateway may still decide at any point to remove the mapping (which usually happens on a reboot of the gateway, when its external IP address changes, or on some models when it detects a port mapping has become inactive, i.e. had no traffic for multiple minutes). If not 0 (permanent), the allowed range according to spec is between 120 (2 minutes) and 86400 seconds (24 hours).
See for possible return values.
Deletes the port mapping for the given port and protocol combination on the default gateway (see ) if one exists. port must be a valid port between 1 and 65535, proto can be either TCP or UDP. May be refused for mappings pointing to addresses other than this one, for well-known ports (below 1024), or for mappings not added via UPnP. See for possible return values.
Universal Plug and Play (UPnP) device. See for UPnP discovery and utility functions. Provides low-level access to UPNP control commands. Allows to manage port mappings (port forwarding) and to query network information of the device (like local and external IP address and status). Note that methods on this class are synchronous and block the calling thread.
OK.
HTTP error.
Empty HTTP response.
Returned response contained no URLs.
Not a valid IGD.
Disconnected.
Unknown device.
Invalid control.
Memory allocation error.
Unknown error.
URL to the device description.
Service type.
IDG control URL.
IGD service type.
Address of the local machine in the network connecting it to this .
IGD status. See .
Returns true if this is a valid IGD (InternetGatewayDevice) which potentially supports port forwarding.
Returns the external IP address of this or an empty string.
Adds a port mapping to forward the given external port on this for the given protocol to the local machine. See .
Deletes the port mapping identified by the given port and protocol combination on this device. See .
Helper to manage undo/redo operations in the editor or custom tools. It works by registering methods and property changes inside "actions".
Common behavior is to create an action, then add do/undo calls to functions or property changes, then committing the action.
Here's an example on how to add an action to the Godot editor's own , from a plugin:
var undo_redo = get_undo_redo() # Method of EditorPlugin.
func do_something():
pass # Put your code here.
func undo_something():
pass # Put here the code that reverts what's done by "do_something()".
func _on_MyButton_pressed():
var node = get_node("MyNode2D")
undo_redo.create_action("Move the node")
undo_redo.add_do_method(self, "do_something")
undo_redo.add_undo_method(self, "undo_something")
undo_redo.add_do_property(node, "position", Vector2(100,100))
undo_redo.add_undo_property(node, "position", node.position)
undo_redo.commit_action()
, , , , , and should be called one after the other, like in the example. Not doing so could lead to crashes.
If you don't need to register a method, you can leave and out; the same goes for properties. You can also register more than one method/property.
Makes "do"/"undo" operations stay in separate actions.
Makes so that the action's "do" operation is from the first action created and the "undo" operation is from the last subsequent action with the same name.
Makes subsequent actions with the same name be merged into one.
Create a new action. After this is called, do all your calls to , , , and , then commit the action with .
The way actions are merged is dictated by the merge_mode argument. See for details.
Commit the action. All "do" methods/properties are called/set when this function is called.
Returns true if the is currently committing the action, i.e. running its "do" method or property change (see ).
Register a method that will be called when the action is committed.
Register a method that will be called when the action is undone.
Register a property value change for "do".
Register a property value change for "undo".
Register a reference for "do" that will be erased if the "do" history is lost. This is useful mostly for new nodes created for the "do" call. Do not use for resources.
Register a reference for "undo" that will be erased if the "undo" history is lost. This is useful mostly for nodes removed with the "do" call (not the "undo" call!).
Clear the undo/redo history and associated references.
Passing false to increase_version will prevent the version number to be increased from this.
Gets the name of the current action.
Returns true if an "undo" action is available.
Returns true if a "redo" action is available.
Gets the version. Every time a new action is committed, the 's version number is increased automatically.
This is useful mostly to check if something changed from a saved version.
Redo the last action.
Undo the last action.
Vertical box container. See .
Vertical version of .
Vertical version of , which goes from top (min) to bottom (max).
Vertical version of . Even though it looks vertical, it is used to separate objects horizontally.
Vertical slider. See . This one goes from bottom (min) to top (max).
Note: The Range.changed and Range.value_changed signals are part of the class which this class inherits from.
Vertical split container. See . This goes from top to bottom.
This node implements all the physics logic needed to simulate a car. It is based on the raycast vehicle system commonly found in physics engines. You will need to add a for the main body of your vehicle and add nodes for the wheels. You should also add a to this node for the 3D model of your car but this model should not include meshes for the wheels. You should control the vehicle by using the , , and properties and not change the position or orientation of this node directly.
Note: The origin point of your VehicleBody will determine the center of gravity of your vehicle so it is better to keep this low and move the and upwards.
Note: This class has known issues and isn't designed to provide realistic 3D vehicle physics. If you want advanced vehicle physics, you will probably have to write your own physics integration using another class.
Accelerates the vehicle by applying an engine force. The vehicle is only sped up if the wheels that have set to true and are in contact with a surface. The of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration.
Note: The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears.
A negative value will result in the vehicle reversing.
Slows down the vehicle by applying a braking force. The vehicle is only slowed down if the wheels are in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking.
The steering angle for the vehicle. Setting this to a non-zero value will result in the vehicle turning when it's moving. Wheels that have set to true will automatically be rotated.
This node needs to be used as a child node of and simulates the behavior of one of its wheels. This node also acts as a collider to detect if the wheel is touching a surface.
Note: This class has known issues and isn't designed to provide realistic 3D vehicle physics. If you want advanced vehicle physics, you will probably have to write your own physics integration using another class.
Accelerates the wheel by applying an engine force. The wheel is only sped up if it is in contact with a surface. The of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration.
Note: The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears.
A negative value will result in the wheel reversing.
Slows down the wheel by applying a braking force. The wheel is only slowed down if it is in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking.
The steering angle for the wheel. Setting this to a non-zero value will result in the vehicle turning when it's moving.
If true, this wheel transfers engine force to the ground to propel the vehicle forward. This value is used in conjunction with and ignored if you are using the per-wheel value instead.
If true, this wheel will be turned when the car steers. This value is used in conjunction with and ignored if you are using the per-wheel value instead.
This value affects the roll of your vehicle. If set to 1.0 for all wheels, your vehicle will be prone to rolling over, while a value of 0.0 will resist body roll.
The radius of the wheel in meters.
This is the distance in meters the wheel is lowered from its origin point. Don't set this to 0.0 and move the wheel into position, instead move the origin point of your wheel (the gizmo in Godot) to the position the wheel will take when bottoming out, then use the rest length to move the wheel down to the position it should be in when the car is in rest.
This determines how much grip this wheel has. It is combined with the friction setting of the surface the wheel is in contact with. 0.0 means no grip, 1.0 is normal grip. For a drift car setup, try setting the grip of the rear wheels slightly lower than the front wheels, or use a lower value to simulate tire wear.
It's best to set this to 1.0 when starting out.
This is the distance the suspension can travel. As Godot units are equivalent to meters, keep this setting relatively low. Try a value between 0.1 and 0.3 depending on the type of car.
This value defines the stiffness of the suspension. Use a value lower than 50 for an off-road car, a value between 50 and 100 for a race car and try something around 200 for something like a Formula 1 car.
The maximum force the spring can resist. This value should be higher than a quarter of the of the or the spring will not carry the weight of the vehicle. Good results are often obtained by a value that is about 3× to 4× this number.
The damping applied to the spring when the spring is being compressed. This value should be between 0.0 (no damping) and 1.0. A value of 0.0 means the car will keep bouncing as the spring keeps its energy. A good value for this is around 0.3 for a normal car, 0.5 for a race car.
The damping applied to the spring when relaxing. This value should be between 0.0 (no damping) and 1.0. This value should always be slightly higher than the property. For a value of 0.3, try a relaxation value of 0.5.
Returns true if this wheel is in contact with a surface.
Returns the contacting body node if valid in the tree, as . At the moment, is not supported so the node will be always of type .
Returns null if the wheel is not in contact with a surface, or the contact body is not a .
Returns a value between 0.0 and 1.0 that indicates whether this wheel is skidding. 0.0 is skidding (the wheel has lost grip, e.g. icy terrain), 1.0 means not skidding (the wheel has full grip, e.g. dry asphalt road).
Returns the rotational speed of the wheel in revolutions per minute.
Control node for playing video streams using resources.
Supported video formats are WebM (.webm, ), Ogg Theora (.ogv, ), and any format exposed via a GDNative plugin using .
Note: Due to a bug, VideoPlayer does not support localization remapping yet.
Warning: On HTML5, video playback will perform poorly due to missing architecture-specific assembly optimizations, especially for VP8/VP9.
The embedded audio track to play.
The assigned video stream. See description for supported formats.
Audio volume in dB.
Audio volume as a linear value.
If true, playback starts when the scene loads.
If true, the video is paused.
If true, the video scales to the control size. Otherwise, the control minimum size will be automatically adjusted to match the video stream's dimensions.
Amount of time in milliseconds to store in buffer while playing.
The current position of the stream, in seconds.
Note: Changing this value won't have any effect as seeking is not implemented yet, except in video formats implemented by a GDNative add-on.
Audio bus to use for sound playback.
Starts the video playback from the beginning. If the video is paused, this will not unpause the video.
Stops the video playback and sets the stream position to 0.
Note: Although the stream position will be set to 0, the first frame of the video stream won't become the current frame.
Returns true if the video is playing.
Note: The video is still considered playing if paused during playback.
Returns the video stream's name, or "<No Stream>" if no video stream is assigned.
Returns the current frame as a .
Base resource type for all video streams. Classes that derive from can all be used as resource types to play back videos in .
resource for video formats implemented via GDNative.
It can be used via godot-videodecoder which uses the FFmpeg library.
Sets the video file that this resource handles. The supported extensions depend on the GDNative plugins used to expose video formats.
Returns the video file handled by this .
resource handling the Ogg Theora video format with .ogv extension. The Theora codec is less efficient than 's VP8 and VP9, but it requires less CPU resources to decode. The Theora codec is decoded on the CPU.
Note: While Ogg Theora videos can also have an .ogg extension, you will have to rename the extension to .ogv to use those videos within Godot.
Sets the Ogg Theora video file that this resource handles. The file name should have the .ogv extension.
Returns the Ogg Theora video file handled by this .
resource handling the WebM video format with .webm extension. Both the VP8 and VP9 codecs are supported. The VP8 and VP9 codecs are more efficient than , but they require more CPU resources to decode (especially VP9). Both the VP8 and VP9 codecs are decoded on the CPU.
Note: Alpha channel (also known as transparency) is not supported. The video will always appear to have a black background, even if it originally contains an alpha channel.
Note: There are known bugs and performance issues with WebM video playback in Godot. If you run into problems, try using the Ogg Theora format instead:
Sets the WebM video file that this resource handles. The file name should have the .webm extension.
Returns the WebM video file handled by this .
A Viewport creates a different view into the screen, or a sub-view inside another viewport. Children 2D Nodes will display on it, and children Camera 3D nodes will render on it too.
Optionally, a viewport can have its own 2D or 3D world, so they don't share what they draw with other viewports.
If a viewport is a child of a , it will automatically take up its size, otherwise it must be set manually.
Viewports can also choose to be audio listeners, so they generate positional audio depending on a 2D or 3D camera child of it.
Also, viewports can be assigned to different screens in case the devices have multiple screens.
Finally, viewports can also behave as render targets, in which case they will not be visible unless the associated texture is used to draw.
Note: By default, a newly created Viewport in Godot 3.x will appear to be upside down. Enabling will display the Viewport with the correct orientation.
Always clear the render target before drawing.
Never clear the render target.
Clear the render target next frame, then switch to .
Amount of objects in frame.
Amount of vertices in frame.
Amount of material changes in frame.
Amount of shader changes in frame.
Amount of surface changes in frame.
Amount of draw calls in frame.
Amount of items or joined items in frame.
Amount of draw calls in frame.
Represents the size of the enum.
Allocates all buffers needed for drawing 2D scenes. This takes less VRAM than the 3D usage modes. Note that 3D rendering effects such as glow and HDR are not available when using this mode.
Allocates buffers needed for 2D scenes without allocating a buffer for screen copy. Accordingly, you cannot read from the screen. Of the types, this requires the least VRAM. Note that 3D rendering effects such as glow and HDR are not available when using this mode.
Allocates full buffers for drawing 3D scenes and all 3D effects including buffers needed for 2D scenes and effects.
Allocates buffers needed for drawing 3D scenes. But does not allocate buffers needed for reading from the screen and post-processing effects. Saves some VRAM.
Objects are displayed normally.
Objects are displayed without light information.
Objected are displayed semi-transparent with additive blending so you can see where they intersect.
Objects are displayed in wireframe style.
This quadrant will not be used.
This quadrant will only be used by one shadow map.
This quadrant will be split in 4 and used by up to 4 shadow maps.
This quadrant will be split 16 ways and used by up to 16 shadow maps.
This quadrant will be split 64 ways and used by up to 64 shadow maps.
This quadrant will be split 256 ways and used by up to 256 shadow maps. Unless the is very high, the shadows in this quadrant will be very low resolution.
This quadrant will be split 1024 ways and used by up to 1024 shadow maps. Unless the is very high, the shadows in this quadrant will be very low resolution.
Represents the size of the enum.
Do not update the render target.
Update the render target once, then switch to .
Update the render target only when it is visible. This is the default value.
Always update the render target.
Multisample anti-aliasing mode disabled. This is the default value.
Use 2x Multisample Antialiasing.
Use 4x Multisample Antialiasing.
Use 8x Multisample Antialiasing. Likely unsupported on low-end and older hardware.
Use 16x Multisample Antialiasing. Likely unsupported on medium and low-end hardware.
If true, the viewport will be used in AR/VR process.
The width and height of viewport. Must be set to a value greater than or equal to 2 pixels on both dimensions. Otherwise, nothing will be displayed.
If true, the size override affects stretch as well.
If true, the viewport will use a unique copy of the defined in .
The custom which can be used as 3D environment source.
The custom which can be used as 2D environment source.
If true, the viewport should render its background as transparent.
The multisample anti-aliasing mode. A higher number results in smoother edges at the cost of significantly worse performance. A value of 4 is best unless targeting very high-end systems.
Enables fast approximate antialiasing. FXAA is a popular screen-space antialiasing method, which is fast but will make the image look blurry, especially at lower resolutions. It can still work relatively well at large resolutions such as 1440p and 4K. Some of the lost sharpness can be recovered by enabling contrast-adaptive sharpening (see ).
If true, uses a fast post-processing filter to make banding significantly less visible. In some cases, debanding may introduce a slightly noticeable dithering pattern. It's recommended to enable debanding only when actually needed since the dithering pattern will make lossless-compressed screenshots larger.
Note: Only available on the GLES3 backend. must also be true for debanding to be effective.
If set to a value greater than 0.0, contrast-adaptive sharpening will be applied to the 3D viewport. This has a low performance cost and can be used to recover some of the sharpness lost from using FXAA. Values around 0.5 generally give the best results. See also .
If true, the viewport rendering will receive benefits from High Dynamic Range algorithm. High Dynamic Range allows the viewport to receive values that are outside the 0-1 range. In Godot, HDR uses half floating-point precision (16-bit) by default. To use full floating-point precision (32-bit), enable .
Note: Requires to be set to or , since HDR is not supported for 2D.
Note: Only available on the GLES3 backend.
If true, allocates the viewport's framebuffer with full floating-point precision (32-bit) instead of half floating-point precision (16-bit). Only effective when is also enabled.
Note: Enabling this setting does not improve rendering quality. Using full floating-point precision is slower, and is generally only needed for advanced shaders that require a high level of precision. To reduce banding, enable instead.
Note: Only available on the GLES3 backend.
If true, the viewport will disable 3D rendering. For actual disabling use usage.
If true, the result after 3D rendering will not have a linear to sRGB color conversion applied. This is important when the viewport is used as a render target where the result is used as a texture on a 3D object rendered in another viewport. It is also important if the viewport is used to create data that is not color based (noise, heightmaps, pickmaps, etc.). Do not enable this when the viewport is used as a texture on a 2D object or if the viewport is your final output. For the GLES2 driver this will convert the sRGB output to linear, this should only be used for VR plugins that require input in linear color space!
The rendering mode of viewport.
Note: If set to or , will have no effect when enabled since HDR is not supported for 2D.
If true, renders the Viewport directly to the screen instead of to the root viewport. Only available in GLES2. This is a low-level optimization and should not be used in most cases. If used, reading from the Viewport or from SCREEN_TEXTURE becomes unavailable. For more information see .
The overlay mode for test rendered geometry in debug purposes.
If true, the result of rendering will be flipped vertically. Since Viewports in Godot 3.x render upside-down, it's recommended to set this to true in most situations.
The clear mode when viewport used as a render target.
Note: This property is intended for 2D usage.
The update mode when viewport used as a render target.
If true, the viewport will process 2D audio streams.
If true, the viewport will process 3D audio streams.
If true, the objects rendered by viewport become subjects of mouse picking process.
If true, the viewport will not receive input events.
If true, the GUI controls on the viewport will lay pixel perfectly.
The shadow atlas' resolution (used for omni and spot lights). The value will be rounded up to the nearest power of 2.
Note: If this is set to 0, both point and directional shadows won't be visible. Since user-created viewports default to a value of 0, this value must be set above 0 manually (typically at least 256).
The subdivision amount of the first quadrant on the shadow atlas.
The subdivision amount of the second quadrant on the shadow atlas.
The subdivision amount of the third quadrant on the shadow atlas.
The subdivision amount of the fourth quadrant on the shadow atlas.
The canvas transform of the viewport, useful for changing the on-screen positions of all child s. This is relative to the global canvas transform of the viewport.
The global canvas transform of the viewport. The canvas transform is relative to this.
Returns the first valid for this viewport, searching the property of itself and any Viewport ancestor.
Returns the first valid for this viewport, searching the property of itself and any Viewport ancestor.
Returns the total transform of the viewport.
Returns the visible rectangle in global screen coordinates.
Sets the size override of the viewport. If the enable parameter is true the override is used, otherwise it uses the default size. If the size parameter is (-1, -1), it won't update the size.
If the parameter is null, then the default value is new Vector2(-1, -1)
If the parameter is null, then the default value is new Vector2(0, 0)
Returns the size override set with .
Returns true if the size override is enabled. See .
Returns information about the viewport from the rendering pipeline.
Returns the viewport's texture.
Note: Due to the way OpenGL works, the resulting is flipped vertically. You can use on the result of to flip it back, for example:
var img = get_viewport().get_texture().get_data()
img.flip_y()
Returns the viewport's RID from the .
Forces update of the 2D and 3D worlds.
Returns the active 3D camera.
Attaches this to the root with the specified rectangle. This bypasses the need for another node to display this but makes you responsible for updating the position of this manually.
Returns the mouse's position in this using the coordinate system of this .
Moves the mouse pointer to the specified position in this using the coordinate system of this .
Returns true if there are visible modals on-screen.
Returns the drag data from the GUI, that was previously returned by .
Returns true if the viewport is currently performing a drag operation.
Alternative to and when you prefer polling the value.
Returns true if the drag operation is successful.
Returns the topmost modal in the stack.
Sets the number of subdivisions to use in the specified quadrant. A higher number of subdivisions allows you to have more shadows in the scene at once, but reduces the quality of the shadows. A good practice is to have quadrants with a varying number of subdivisions and to have as few subdivisions as possible.
Returns the of the specified quadrant.
Stops the input from propagating further down the .
A node that holds a , automatically setting its size.
Note: Changing a ViewportContainer's will cause its contents to appear distorted. To change its visual size without causing distortion, adjust the node's margins instead (if it's not already in a container).
If true, the viewport will be scaled to the control's size.
Divides the viewport's effective resolution by this value while preserving its scale. This can be used to speed up rendering.
For example, a 1280×720 viewport with set to 2 will be rendered at 640×360 while occupying the same size in the container.
Note: must be true for this property to work.
Displays the content of a node as a dynamic . This can be used to mix controls, 2D, and 3D elements in the same scene.
To create a ViewportTexture in code, use the method on the target viewport.
The path to the node to display. This is relative to the scene root, not to the node which uses the texture.
The VisibilityEnabler will disable and nodes when they are not visible. It will only affect other nodes within the same scene as the VisibilityEnabler itself.
If you just want to receive notifications, use instead.
Note: VisibilityEnabler uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account (unless you are using s). The heuristic is an implementation detail and may change in future versions. If you need precise visibility checking, use another method such as adding an node as a child of a node and/or Vector3.dot.
Note: VisibilityEnabler will not affect nodes added after scene initialization.
This enabler will pause nodes.
This enabler will freeze nodes.
Represents the size of the enum.
If true, nodes will be paused.
If true, nodes will be paused.
Sets active state of the enabler identified by given constant.
Returns whether the enabler identified by given constant is active.
The VisibilityEnabler2D will disable , , and other nodes when they are not visible. It will only affect nodes with the same root node as the VisibilityEnabler2D, and the root node itself.
If you just want to receive notifications, use instead.
Note: For performance reasons, VisibilityEnabler2D uses an approximate heuristic with precision determined by . If you need precise visibility checking, use another method such as adding an node as a child of a node.
Note: VisibilityEnabler2D will not affect nodes added after scene initialization.
This enabler will pause nodes.
This enabler will freeze nodes.
This enabler will stop nodes.
This enabler will stop the parent's function.
This enabler will stop the parent's function.
This enabler will stop nodes animations.
Represents the size of the enum.
If true, nodes will be paused.
If true, nodes will be paused.
If true, nodes will be paused.
If true, nodes will be paused.
If true, the parent's will be stopped.
If true, the parent's will be stopped.
Sets active state of the enabler identified by given constant.
Returns whether the enabler identified by given constant is active.
The VisibilityNotifier detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a 's view.
If you want nodes to be disabled automatically when they exit the screen, use instead.
Note: VisibilityNotifier uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account (unless you are using s). The heuristic is an implementation detail and may change in future versions. If you need precise visibility checking, use another method such as adding an node as a child of a node and/or Vector3.dot.
The VisibilityNotifier's bounding box.
In addition to checking whether a node is on screen or within a 's view, VisibilityNotifier can also optionally check whether a node is within a specified maximum distance when using a with perspective projection. This is useful for throttling the performance requirements of nodes that are far away.
Note: This feature will be disabled if set to 0.0.
If true, the bounding box is on the screen.
Note: It takes one frame for the node's visibility to be assessed once added to the scene tree, so this method will return false right after it is instantiated, even if it will be on screen in the draw pass.
The VisibilityNotifier2D detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a viewport.
If you want nodes to be disabled automatically when they exit the screen, use instead.
Note: For performance reasons, VisibilityNotifier2D uses an approximate heuristic with precision determined by . If you need precise visibility checking, use another method such as adding an node as a child of a node.
The VisibilityNotifier2D's bounding rectangle.
If true, the bounding rectangle is on the screen.
Note: It takes one frame for the node's visibility to be assessed once added to the scene tree, so this method will return false right after it is instantiated, even if it will be on screen in the draw pass.
The is used to connect a resource to a visual representation. All visual 3D nodes inherit from the . In general, you should not access the properties directly as they are accessed and managed by the nodes that inherit from . is the node representation of the instance.
The render layer(s) this is drawn on.
This object will only be visible for s whose cull mask includes the render object this is set to.
Sets the resource that is instantiated by this , which changes how the engine handles the under the hood. Equivalent to .
Returns the RID of the resource associated with this . For example, if the Node is a , this will return the RID of the associated .
Returns the RID of this instance. This RID is the same as the RID returned by . This RID is needed if you want to call functions directly on this .
Enables a particular layer in .
Returns true when the specified layer is enabled in and false otherwise.
Returns the transformed (also known as the bounding box) for this .
Transformed in this case means the plus the position, rotation, and scale of the 's . See also .
Returns the (also known as the bounding box) for this . See also .
A script implemented in the Visual Script programming environment. The script extends the functionality of all objects that instance it.
extends an existing object, if that object's class matches one of the script's base classes.
You are most likely to use this class via the Visual Script editor or when writing plugins for it.
Add a function with the specified name to the VisualScript.
Returns whether a function exists with the specified name.
Remove a specific function and its nodes from the script.
Change the name of a function.
Position the center of the screen for a function.
Returns the position of the center of the screen for a given function.
Add a node to a function of the VisualScript.
If the parameter is null, then the default value is new Vector2(0, 0)
Remove a specific node.
Returns the id of a function's entry point node.
Returns a node given its id and its function.
Returns whether a node exists with the given id.
Position a node on the screen.
Returns a node's position in pixels.
Connect two sequence ports. The execution will flow from of from_node's from_output into to_node.
Unlike , there isn't a to_port, since the target node can have only one sequence port.
Disconnect two sequence ports previously connected with .
Returns whether the specified sequence ports are connected.
Connect two data ports. The value of from_node's from_port would be fed into to_node's to_port.
Disconnect two data ports previously connected with .
Returns whether the specified data ports are connected.
Add a variable to the VisualScript, optionally giving it a default value or marking it as exported.
Returns whether a variable exists with the specified name.
Remove a variable with the given name.
Change the default (initial) value of a variable.
Returns the default (initial) value of a variable.
Set a variable's info, using the same format as .
Returns the information for a given variable as a dictionary. The information includes its name, type, hint and usage.
Change whether a variable is exported.
Returns whether a variable is exported.
Change the name of a variable.
Add a custom signal with the specified name to the VisualScript.
Returns whether a signal exists with the specified name.
Add an argument to a custom signal added with .
Change the type of a custom signal's argument.
Get the type of a custom signal's argument.
Rename a custom signal's argument.
Get the name of a custom signal's argument.
Remove a specific custom signal's argument.
Get the count of a custom signal's arguments.
Swap two of the arguments of a custom signal.
Remove a custom signal with the given name.
Change the name of a custom signal.
Set the base type of the script.
A Visual Script node representing a constant from base types, such as Vector3.AXIS_X.
The type to get the constant from.
The name of the constant to return.
A built-in function used inside a . It is usually a math function or an utility function.
See also @GDScript, for the same functions in the GDScript language.
Return the sine of the input.
Return the cosine of the input.
Return the tangent of the input.
Return the hyperbolic sine of the input.
Return the hyperbolic cosine of the input.
Return the hyperbolic tangent of the input.
Return the arc sine of the input.
Return the arc cosine of the input.
Return the arc tangent of the input.
Return the arc tangent of the input, using the signs of both parameters to determine the exact angle.
Return the square root of the input.
Return the remainder of one input divided by the other, using floating-point numbers.
Return the positive remainder of one input divided by the other, using floating-point numbers.
Return the input rounded down.
Return the input rounded up.
Return the input rounded to the nearest integer.
Return the absolute value of the input.
Return the sign of the input, turning it into 1, -1, or 0. Useful to determine if the input is positive or negative.
Return the input raised to a given power.
Return the natural logarithm of the input. Note that this is not the typical base-10 logarithm function calculators use.
Return the mathematical constant e raised to the specified power of the input. e has an approximate value of 2.71828.
Return whether the input is NaN (Not a Number) or not. NaN is usually produced by dividing 0 by 0, though other ways exist.
Return whether the input is an infinite floating-point number or not. Infinity is usually produced by dividing a number by 0, though other ways exist.
Easing function, based on exponent. 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in.
Return the number of digit places after the decimal that the first non-zero digit occurs.
Return the input snapped to a given step.
Return a number linearly interpolated between the first two inputs, based on the third input. Uses the formula a + (a - b) * t.
Moves the number toward a value, based on the third input.
Return the result of value decreased by step * amount.
Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
Return a random 32 bits integer value. To obtain a random value between 0 to N (where N is smaller than 2^32 - 1), you can use it with the remainder function.
Return a random floating-point value between 0 and 1. To obtain a random value between 0 to N, you can use it with multiplication.
Return a random floating-point value between the two inputs.
Set the seed for the random number generator.
Return a random value from the given seed, along with the new seed.
Convert the input from degrees to radians.
Convert the input from radians to degrees.
Convert the input from linear volume to decibel volume.
Convert the input from decibel volume to linear volume.
Converts a 2D point expressed in the polar coordinate system (a distance from the origin r and an angle th) to the cartesian coordinate system (X and Y axis).
Converts a 2D point expressed in the cartesian coordinate system (X and Y axis) to the polar coordinate system (a distance from the origin and an angle).
Return the greater of the two numbers, also known as their maximum.
Return the lesser of the two numbers, also known as their minimum.
Return the input clamped inside the given range, ensuring the result is never outside it. Equivalent to min(max(input, range_low), range_high).
Return the nearest power of 2 to the input.
Create a from the input.
Create a from the input.
Convert between types.
Return the type of the input as an integer. Check for the integers that might be returned.
Checks if a type is registered in the .
Return a character with the given ascii value.
Convert the input to a string.
Print the given string to the output window.
Print the given string to the standard error output.
Print the given string to the standard output, without adding a newline.
Serialize a Variant to a string.
Deserialize a Variant from a string serialized using .
Serialize a Variant to a .
Deserialize a Variant from a serialized using .
Return the with the given name and alpha ranging from 0 to 1.
Note: Names are defined in color_names.inc.
Return a number smoothly interpolated between the first two inputs, based on the third input. Similar to , but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula:
var t = clamp((weight - from) / (to - from), 0.0, 1.0)
return t * t * (3.0 - 2.0 * t)
Represents the size of the enum.
The function to be executed.
This node returns a constant from a given class, such as TYPE_INT. See the given class' documentation for available constants.
Input Ports:
none
Output Ports:
- Data (variant): value
The constant's parent class.
The constant to return. See the given class for its available constants.
A Visual Script node used to display annotations in the script, so that code may be documented.
Comment nodes can be resized so they encompass a group of nodes.
The comment node's title.
The text inside the comment node.
The comment node's size (in pixels).
A Visual Script Node used to compose array from the list of elements provided with custom in-graph UI hard coded in the VisualScript Editor.
A Visual Script node that checks a input port. If true, it will exit via the "true" sequence port. If false, it will exit via the "false" sequence port. After exiting either, it exits via the "done" port. Sequence ports may be left disconnected.
Input Ports:
- Sequence: if (cond) is
- Data (boolean): cond
Output Ports:
- Sequence: true
- Sequence: false
- Sequence: done
This node returns a constant's value.
Input Ports:
none
Output Ports:
- Data (variant): get
The constant's type.
The constant's value.
A Visual Script node which calls a base type constructor. It can be used for type conversion as well.
A custom Visual Script node which can be scripted in powerful ways.
Hint used by to tell that control should return to it when there is no other node left to execute.
This is used by to redirect the sequence to the "Done" port after the true/false branch has finished execution.
Hint used by to tell that control should return back, either hitting a previous or exiting the function.
Hint used by to tell that control should stop and exit the function.
Hint used by to tell that the function should be yielded.
Using this requires you to have at least one working memory slot, which is used for the .
The start mode used the first time when is called.
The start mode used when is called after coming back from a .
The start mode used when is called after resuming from .
Return the node's title.
Return the node's category.
Return the count of input value ports.
Return the specified input port's hint. See the hints.
Return the specified input port's hint string.
Return the specified input port's name.
Return the specified input port's type. See the values.
Return the amount of output sequence ports.
Return the specified sequence output's name.
Return the amount of output value ports.
Return the specified output port's hint. See the hints.
Return the specified output port's hint string.
Return the specified output port's name.
Return the specified output port's type. See the values.
Return the custom node's text, which is shown right next to the input sequence port (if there is none, on the place that is usually taken by it).
Return the size of the custom node's working memory. See for more details.
Return whether the custom node has an input sequence port.
Execute the custom node's logic, returning the index of the output sequence port to use or a when there is an error.
The inputs array contains the values of the input ports.
outputs is an array whose indices should be set to the respective outputs.
The start_mode is usually , unless you have used the STEP_* constants.
working_mem is an array which can be used to persist information between runs of the custom node. The size needs to be predefined using .
When returning, you can mask the returned value with one of the STEP_* constants.
A Visual Script node which deconstructs a base type instance into its parts.
The type to deconstruct.
Emits a specified signal when it is executed.
Input Ports:
- Sequence: emit
Output Ports:
- Sequence
The signal to emit.
A Visual Script node returning a singleton from @GlobalScope.
The singleton's name.
A Visual Script node that can execute a custom expression. Values can be provided for the input and the expression result can be retrieved from the output.
represents a function header. It is the starting point for the function body and can be used to tweak the function's properties (e.g. RPC mode).
is created when you add or drag and drop a function onto the Visual Script graph. It allows to tweak parameters of the call, e.g. what object the function is called on.
The method will be called locally.
The method will be called remotely.
The method will be called remotely using an unreliable protocol.
The method will be called remotely for the given peer.
The method will be called remotely for the given peer, using an unreliable protocol.
The method will be called on this .
The method will be called on the given in the scene tree.
The method will be called on an instanced node with the given type and script.
The method will be called on a GDScript basic type (e.g. ).
The method will be called on a singleton.
call_mode determines the target object on which the method will be called. See for options.
The base type to be used when is set to .
The script to be used when is set to .
The singleton to call the method on. Used when is set to .
The type to be used when is set to .
The node path to use when is set to .
The name of the function to be called.
Number of default arguments that will be used when calling the function. Can't be higher than the number of available default arguments in the method's declaration.
If false, call errors (e.g. wrong number of arguments) will be ignored.
The mode for RPC calls. See for more details and for available options.
is returned from and can be used to resume a paused function call.
Connects this to a signal in the given object to automatically resume when it's emitted.
Resumes the function to run from the point it was yielded.
Returns whether the function state is valid.
A Visual Script node returning a constant from @GlobalScope.
The constant to be used.
will return the value stored in an array or a dictionary under the given index.
will set the value stored in an array or a dictionary under the given index to the provided new value.
can be used to check if an action is pressed or released.
True if action is pressed.
True if action is released (i.e. not pressed).
True on the frame the action was pressed.
True on the frame the action was released.
Name of the action.
State of the action to check. See for options.
This node steps through each item in a given input. Input can be any sequence data type, such as an or . When each item has been processed, execution passed out the exit Sequence port.
Input Ports:
- Sequence: for (elem) in (input)
- Data (variant): input
Output Ports:
- Sequence: each
- Sequence: exit
- Data (variant): elem
A Visual Script virtual class that defines the shape and the default behavior of the nodes that have to be in-graph editable nodes.
Adds an input port to the Visual Script node.
Sets the name of an input port.
Sets the type of an input port.
Removes an input port from the Visual Script node.
Adds an output port to the Visual Script node.
Sets the name of an output port.
Sets the type of an output port.
Removes an output port from the Visual Script node.
Returns a local variable's value. "Var Name" must be supplied, with an optional type.
Input Ports:
none
Output Ports:
- Data (variant): get
The local variable's name.
The local variable's type.
Changes a local variable's value to the given input. The new value is also provided on an output Data port.
Input Ports:
- Sequence
- Data (variant): set
Output Ports:
- Sequence
- Data (variant): get
The local variable's name.
The local variable's type.
Provides common math constants, such as Pi, on an output Data port.
Input Ports:
none
Output Ports:
- Data (variant): get
Unity: 1.
Pi: 3.141593.
Pi divided by two: 1.570796.
Tau: 6.283185.
Mathematical constant e, the natural log base: 2.718282.
Square root of two: 1.414214.
Infinity: inf.
Not a number: nan.
Represents the size of the enum.
The math constant.
A node which is part of a . Not to be confused with , which is a part of a .
Returns the instance the node is bound to.
Change the default value of a given port.
Returns the default value of a given port. The default value is used when nothing is connected to the port.
Notify that the node's ports have changed. Usually used in conjunction with .
Input Ports:
- Data (variant): A
- Data (variant): B
Output Ports:
- Data (variant): result
The operation to be performed. See for available options.
The type of the values for this operation. See for available options.
Creates a new or loads one from the filesystem.
Input Ports:
none
Output Ports:
- Data (object): res
The to load.
can return a value of any property from the current object or other objects.
The property will be retrieved from this .
The property will be retrieved from the given in the scene tree.
The property will be retrieved from an instanced node with the given type and script.
The property will be retrieved from a GDScript basic type (e.g. ).
set_mode determines the target object from which the property will be retrieved. See for options.
The base type to be used when is set to .
The script to be used when is set to .
The type to be used when is set to .
The node path to use when is set to .
The name of the property to retrieve. Changing this will clear .
The indexed name of the property to retrieve. See for details.
can set the value of any property from the current object or other objects.
The property will be assigned regularly.
The value will be added to the property. Equivalent of doing +=.
The value will be subtracted from the property. Equivalent of doing -=.
The property will be multiplied by the value. Equivalent of doing *=.
The property will be divided by the value. Equivalent of doing /=.
A modulo operation will be performed on the property and the value. Equivalent of doing %=.
The property will be binarly shifted to the left by the given value. Equivalent of doing <<.
The property will be binarly shifted to the right by the given value. Equivalent of doing >>.
A binary AND operation will be performed on the property. Equivalent of doing &=.
A binary OR operation will be performed on the property. Equivalent of doing |=.
A binary XOR operation will be performed on the property. Equivalent of doing ^=.
The property will be set on this .
The property will be set on the given in the scene tree.
The property will be set on an instanced node with the given type and script.
The property will be set on a GDScript basic type (e.g. ).
set_mode determines the target object on which the property will be set. See for options.
The base type to be used when is set to .
The script to be used when is set to .
The type to be used when is set to .
The node path to use when is set to .
The name of the property to set. Changing this will clear .
The indexed name of the property to set. See for details.
The additional operation to perform when assigning. See for options.
Ends the execution of a function and returns control to the calling function. Optionally, it can return a Variant value.
Input Ports:
- Sequence
- Data (variant): result (optional)
Output Ports:
none
If true, the return input port is available.
The return value's data type.
A direct reference to a node.
Input Ports:
none
Output Ports:
- Data: node (obj)
The node's path in the scene tree.
A Visual Script node for accessing methods.
Chooses between two input values based on a Boolean condition.
Input Ports:
- Data (boolean): cond
- Data (variant): a
- Data (variant): b
Output Ports:
- Data (variant): out
The input variables' type.
Provides a reference to the node running the visual script.
Input Ports:
none
Output Ports:
- Data (object): instance
Steps through a series of one or more output Sequence ports. The current data port outputs the currently executing item.
Input Ports:
- Sequence: in order
Output Ports:
- Sequence: 1
- Sequence: 2 - n (optional)
- Data (int): current
The number of steps in the sequence.
will call method named _subcall in the current script. It will fail if the method doesn't exist or the provided arguments are wrong.
Called by this node.
Branches the flow based on an input's value. Use Case Count in the Inspector to set the number of branches and each comparison's optional type.
Input Ports:
- Sequence: 'input' is
- Data (variant): =
- Data (variant): = (optional)
- Data (variant): input
Output Ports:
- Sequence
- Sequence (optional)
- Sequence: done
will perform a type conversion to an -derived type.
The target type to be converted to.
The target script class to be converted to. If none, only the will be used.
Returns a variable's value. "Var Name" must be supplied, with an optional type.
Input Ports:
none
Output Ports:
- Data (variant): value
The variable's name.
Changes a variable's value to the given input.
Input Ports:
- Sequence
- Data (variant): set
Output Ports:
- Sequence
The variable's name.
Loops while a condition is true. Execution continues out the exit Sequence port when the loop terminates.
Input Ports:
- Sequence: while(cond)
- Data (bool): cond
Output Ports:
- Sequence: repeat
- Sequence: exit
will pause the function call and return , which can be used to resume the function.
Yields during an idle frame.
Yields during a physics frame.
Yields a function and waits the given time.
The mode to use for yielding. See for available options.
The time to wait when is set to .
will pause the function execution until the provided signal is emitted.
A signal from this will be used.
A signal from the given in the scene tree will be used.
A signal from an instanced node with the given type will be used.
call_mode determines the target object to wait for the signal emission. See for options.
The base type to be used when is set to .
The node path to use when is set to .
The signal name to be waited for.
Server for anything visible. The visual server is the API backend for everything visible. The whole scene system mounts on it to display.
The visual server is completely opaque, the internals are entirely implementation specific and cannot be accessed.
The visual server can be used to bypass the scene system entirely.
Resources are created using the *_create functions.
All objects are drawn to a viewport. You can use the attached to the or you can create one yourself with . When using a custom scenario or canvas, the scenario or canvas needs to be attached to the viewport using or .
In 3D, all visual objects must be associated with a scenario. The scenario is a visual representation of the world. If accessing the visual server from a running game, the scenario can be accessed from the scene tree from any node with . Otherwise, a scenario can be created with .
Similarly, in 2D, a canvas is needed to draw all canvas items.
In 3D, all visible objects are comprised of a resource and an instance. A resource can be a mesh, a particle system, a light, or any other 3D object. In order to be visible resources must be attached to an instance using . The instance must also be attached to the scenario using in order to be visible.
In 2D, all visible objects are some form of canvas item. In order to be visible, a canvas item needs to be the child of a canvas attached to a viewport, or it needs to be the child of another canvas item that is eventually attached to the canvas.
Marks an error that shows that the index array is empty.
Number of weights/bones per vertex.
The minimum Z-layer for canvas items.
The maximum Z-layer for canvas items.
Max number of glow levels that can be used with glow post-process effect.
Unused enum in Godot 3.x.
The minimum renderpriority of all materials.
The maximum renderpriority of all materials.
Reflection probe will update reflections once and then stop.
Reflection probe will update each frame. This mode is necessary to capture moving objects.
Keeps shadows stable as camera moves but has lower effective resolution.
Optimize use of shadow maps, increasing the effective resolution. But may result in shadows moving or flickering slightly.
Blend shapes are normalized.
Blend shapes are relative to base weight.
Primitive to draw consists of points.
Primitive to draw consists of lines.
Primitive to draw consists of a line strip from start to end.
Primitive to draw consists of a line loop (a line strip with a line between the last and the first vertex).
Primitive to draw consists of triangles.
Primitive to draw consists of a triangle strip (the last 3 vertices are always combined to make a triangle).
Primitive to draw consists of a triangle strip (the last 2 vertices are always combined with the first to make a triangle).
Represents the size of the enum.
Normal texture with 2 dimensions, width and height.
Texture made up of six faces, can be looked up with a vec3 in shader.
An array of 2-dimensional textures.
A 3-dimensional texture with width, height, and depth.
Used to query for any changes that request a redraw, whatever the priority.
Registered changes which have low priority can be optionally prevented from causing editor redraws. Examples might include dynamic shaders (typically using the TIME built-in).
Registered changes which can cause a redraw default to high priority.
Lowest quality of screen space ambient occlusion.
Medium quality screen space ambient occlusion.
Highest quality screen space ambient occlusion.
Use lowest blur quality. Fastest, but may look bad.
Use medium blur quality.
Used highest blur quality. Looks the best, but is the slowest.
The amount of objects in the frame.
The amount of vertices in the frame.
The amount of modified materials in the frame.
The amount of shader rebinds in the frame.
The peak amount of shaders that have been under compilation in the frame.
This is useful to know when asynchronous shader compilation has finished for the current shaders on screen.
Note: For complete certainty, only assume there are no outstanding compilations when this value is zero for at least two frames in a row.
Unimplemented in the GLES2 rendering backend, always returns 0.
The amount of surface changes in the frame.
The amount of draw calls in frame.
The amount of 2d items in the frame.
The amount of 2d draw calls in frame.
Unimplemented in the GLES2 and GLES3 rendering backends, always returns 0.
The amount of video memory used, i.e. texture and vertex memory combined.
The amount of texture memory used.
The amount of vertex memory used.
The nine patch gets stretched where needed.
The nine patch gets filled with tiles where needed.
The nine patch gets filled with tiles where needed and stretches them a bit if needed.
Number of objects drawn in a single frame.
Number of vertices drawn in a single frame.
Number of material changes during this frame.
Number of shader changes during this frame.
Number of surface changes during this frame.
Number of draw calls during this frame.
Number of 2d items drawn this frame.
Number of 2d draw calls during this frame.
Represents the size of the enum.
The viewport is always cleared before drawing.
The viewport is never cleared before drawing.
The viewport is cleared once, then the clear mode is set to .
Use more detail vertically when computing shadow map.
Use more detail horizontally when computing shadow map.
Shader is a 3D shader.
Shader is a 2D shader.
Shader is a particle shader.
Represents the size of the enum.
Use to store MultiMesh transform.
Use to store MultiMesh transform.
Disable shadows from this instance.
Cast shadows from this instance.
Disable backface culling when rendering the shadow of the object. This is slightly slower but may result in more correct shadows.
Only render the shadows from the object. The object itself will not be drawn.
Debug draw is disabled. Default setting.
Debug draw sets objects to unshaded.
Overwrites clear color to (0,0,0,0).
Debug draw draws objects in wireframe.
The Viewport does not render 3D but samples.
The Viewport does not render 3D and does not sample.
The Viewport renders 3D with effects.
The Viewport renders 3D but without effects.
Use the clear color as background.
Use a specified color as the background.
Use a sky resource for the background.
Use a custom color for background, but use a sky for shading and reflections.
Use a specified canvas layer as the background. This can be useful for instantiating a 2D scene in a 3D world.
Do not clear the background, use whatever was rendered last frame as the background.
Represents the size of the enum.
MultiMesh does not use custom data.
MultiMesh custom data uses 8 bits per component. This packs the 4-component custom data into a single float.
MultiMesh custom data uses a float per component.
Use a dual paraboloid shadow map for omni lights.
Use a cubemap shadow map for omni lights. Slower but better quality than dual paraboloid.
Generates mipmaps, which are smaller versions of the same texture to use when zoomed out, keeping the aspect ratio.
Repeats the texture (instead of clamp to edge).
Uses a magnifying filter, to enable smooth zooming in of the texture.
Uses anisotropic mipmap filtering. Generates smaller versions of the same texture with different aspect ratios.
This results in better-looking textures when viewed from oblique angles.
Converts the texture to the sRGB color space.
Repeats the texture with alternate sections mirrored.
Texture is a video surface.
Default flags. , and are enabled.
Hardware supports shaders. This enum is currently unused in Godot 3.x.
Hardware supports multithreading. This enum is currently unused in Godot 3.x.
The instance does not have a type.
The instance is a mesh.
The instance is a multimesh.
The instance is an immediate geometry.
The instance is a particle emitter.
The instance is a light.
The instance is a reflection probe.
The instance is a GI probe.
The instance is a lightmap capture.
Represents the size of the enum.
A combination of the flags of geometry instances (mesh, multimesh, immediate and particles).
Disables the blur set for SSAO. Will make SSAO look noisier.
Perform a 1x1 blur on the SSAO output.
Performs a 2x2 blur on the SSAO output.
Performs a 3x3 blur on the SSAO output. Use this for smoothest SSAO.
Output color as they came in. This can cause bright lighting to look blown out, with noticeable clipping in the output colors.
Use the Reinhard tonemapper. Performs a variation on rendered pixels' colors by this formula: color = color / (1 + color). This avoids clipping bright highlights, but the resulting image can look a bit dull.
Use the filmic tonemapper. This avoids clipping bright highlights, with a resulting image that usually looks more vivid than .
Use the legacy Godot version of the Academy Color Encoding System tonemapper. Unlike , this version of ACES does not handle bright lighting in a physically accurate way. ACES typically has a more contrasted output compared to and .
Note: This tonemapping operator will be removed in Godot 4.0 in favor of the more accurate .
Use the Academy Color Encoding System tonemapper. ACES is slightly more expensive than other options, but it handles bright lighting in a more realistic fashion by desaturating it as it becomes brighter. ACES typically has a more contrasted output compared to and .
Add the effect of the glow on top of the scene.
Blends the glow effect with the screen. Does not get as bright as additive.
Produces a subtle color disturbance around objects.
Shows the glow effect by itself without the underlying scene.
MultiMesh does not use per-instance color.
MultiMesh color uses 8 bits per component. This packs the color into a single float.
MultiMesh color uses a float per channel.
Do not apply a filter to canvas light shadows.
Use PCF3 filtering to filter canvas light shadows.
Use PCF5 filtering to filter canvas light shadows.
Use PCF7 filtering to filter canvas light shadows.
Use PCF9 filtering to filter canvas light shadows.
Use PCF13 filtering to filter canvas light shadows.
Do not use a debug mode.
Draw all objects as wireframe models.
Draw all objects in a way that displays how much overdraw is occurring. Overdraw occurs when a section of pixels is drawn and shaded and then another object covers it up. To optimize a scene, you should reduce overdraw.
Draw all objects without shading. Equivalent to setting all objects shaders to unshaded.
Do not update the viewport.
Update the viewport once then set to disabled.
Update the viewport whenever it is visible.
Always update the viewport.
Flag used to mark a vertex array.
Flag used to mark a normal array.
Flag used to mark a tangent array.
Flag used to mark a color array.
Flag used to mark an UV coordinates array.
Flag used to mark an UV coordinates array for the second UV coordinates.
Flag used to mark a bone information array.
Flag used to mark a weights array.
Flag used to mark an index array.
Flag used to mark a compressed (half float) vertex array.
Flag used to mark a compressed (half float) normal array.
Flag used to mark a compressed (half float) tangent array.
Flag used to mark a compressed (half float) color array.
Flag used to mark a compressed (half float) UV coordinates array.
Flag used to mark a compressed (half float) UV coordinates array for the second UV coordinates.
Flag used to mark a compressed bone array.
Flag used to mark a compressed (half float) weight array.
Flag used to mark a compressed index array.
Flag used to mark that the array contains 2D vertices.
Flag used to mark that the array uses 16-bit bones instead of 8-bit.
Flag used to mark that the array uses an octahedral representation of normal and tangent vectors rather than cartesian.
Used to set flags , , , , , , and quickly.
Draw particles in the order that they appear in the particles array.
Sort particles based on their lifetime.
Sort particles based on their distance to the camera.
Adds light color additive to the canvas.
Adds light color subtractive to the canvas.
The light adds color depending on transparency.
The light adds color depending on mask.
Use orthogonal shadow projection for directional light.
Use 2 splits for shadow projection when using directional light.
Use 4 splits for shadow projection when using directional light.
The light's energy.
Secondary multiplier used with indirect light (light bounces).
The light's size, currently only used for soft shadows in baked lightmaps.
The light's influence on specularity.
The light's range.
The light's attenuation.
The spotlight's angle.
The spotlight's attenuation.
Scales the shadow color.
Max distance that shadows will be rendered.
Proportion of shadow atlas occupied by the first split.
Proportion of shadow atlas occupied by the second split.
Proportion of shadow atlas occupied by the third split. The fourth split occupies the rest.
Normal bias used to offset shadow lookup by object normal. Can be used to fix self-shadowing artifacts.
Bias the shadow lookup to fix self-shadowing artifacts.
Increases bias on further splits to fix self-shadowing that only occurs far away from the camera.
Represents the size of the enum.
Array is a vertex array.
Array is a normal array.
Array is a tangent array.
Array is a color array.
Array is an UV coordinates array.
Array is an UV coordinates array for the second UV coordinates.
Array contains bone information.
Array is weight information.
Array is index array.
Represents the size of the enum.
Culling of the canvas occluder is disabled.
Culling of the canvas occluder is clockwise.
Culling of the canvas occluder is counterclockwise.
Allows the instance to be used in baked lighting.
When set, manually requests to draw geometry on next frame.
Represents the size of the enum.
Multisample antialiasing is disabled.
Multisample antialiasing is set to 2×.
Multisample antialiasing is set to 4×.
Multisample antialiasing is set to 8×.
Multisample antialiasing is set to 16×.
Multisample antialiasing is set to 2× on external texture. Special mode for GLES2 Android VR (Oculus Quest and Go).
Multisample antialiasing is set to 4× on external texture. Special mode for GLES2 Android VR (Oculus Quest and Go).
Is a directional (sun) light.
Is an omni light.
Is a spot light.
Marks the left side of a cubemap.
Marks the right side of a cubemap.
Marks the bottom side of a cubemap.
Marks the top side of a cubemap.
Marks the front side of a cubemap.
Marks the back side of a cubemap.
If false, disables rendering completely, but the engine logic is still being processed. You can call to draw a frame even with rendering disabled.
Synchronizes threads.
Forces a frame to be drawn when the function is called. Drawing a frame updates all s that are set to update. Use with extreme caution.
Not implemented in Godot 3.x.
Draws a frame. This method is deprecated, please use instead.
Creates an empty texture and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all texture_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Creates a texture, allocates the space for an image, and fills in the image.
Allocates the GPU memory for the texture.
Sets the texture's image data. If it's a CubeMap, it sets the image data at a cube side.
Sets a part of the data for a texture. Warning: this function calls the underlying graphics API directly and may corrupt your texture if used improperly.
Returns a copy of a texture's image unless it's a CubeMap, in which case it returns the of the image at one of the cubes sides.
Sets the texture's flags. See for options.
Returns the flags of a texture.
Returns the format of the texture's image.
Returns the type of the texture, can be any of the .
Returns the opengl id of the texture's image.
Returns the texture's width.
Returns the texture's height.
Returns the depth of the texture.
Resizes the texture to the specified dimensions.
Sets the texture's path.
Returns the texture's path.
If true, sets internal processes to shrink all image data to half the size.
Creates an update link between two textures, similar to how s operate. When the base texture is the texture of a , every time the viewport renders a new frame, the proxy texture automatically receives an update.
For example, this code links a generic to the texture output of the using the VisualServer API:
func _ready():
var viewport_rid = get_viewport().get_viewport_rid()
var viewport_texture_rid = VisualServer.viewport_get_texture(viewport_rid)
var proxy_texture = ImageTexture.new()
var viewport_texture_image_data = VisualServer.texture_get_data(viewport_texture_rid)
proxy_texture.create_from_image(viewport_texture_image_data)
var proxy_texture_rid = proxy_texture.get_rid()
VisualServer.texture_set_proxy(proxy_texture_rid, viewport_texture_rid)
$TextureRect.texture = proxy_texture
Binds the texture to a texture slot.
Returns a list of all the textures and their information.
If true, the image will be stored in the texture's images array if overwritten.
Creates an empty sky and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all sky_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Sets a sky's texture.
Creates an empty shader and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all shader_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Sets a shader's code.
Returns a shader's code.
Returns the parameters of a shader.
Sets a shader's default texture. Overwrites the texture given by name.
Returns a default texture from a shader searched by name.
If asynchronous shader compilation is enabled, this controls whether is obeyed.
For instance, you may want to enable this temporarily before taking a screenshot. This ensures everything is visible even if shaders with async mode hidden are not ready yet.
Reflection probes use this internally to ensure they capture everything regardless the shaders are ready or not.
Creates an empty material and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all material_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Sets a shader material's shader.
Returns the shader of a certain material's shader. Returns an empty RID if the material doesn't have a shader.
Sets a material's parameter.
Returns the value of a certain material's parameter.
Returns the default value for the param if available. Returns null otherwise.
Sets a material's render priority.
Sets a material's line width.
Sets an object's next material.
Creates a new mesh and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all mesh_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
To place in a scene, attach this mesh to an instance using using the returned RID.
Function is unused in Godot 3.x.
Adds a surface generated from the Arrays to a mesh. See constants for types.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Sets a mesh's blend shape count.
Returns a mesh's blend shape count.
Sets a mesh's blend shape mode.
Returns a mesh's blend shape mode.
Updates a specific region of a vertex buffer for the specified surface. Warning: this function alters the vertex buffer directly with no safety mechanisms, you can easily corrupt your mesh.
Sets a mesh's surface's material.
Returns a mesh's surface's material.
Returns a mesh's surface's amount of vertices.
Returns a mesh's surface's amount of indices.
Returns a mesh's surface's vertex buffer.
Returns a mesh's surface's index buffer.
Returns a mesh's surface's buffer arrays.
Returns a mesh's surface's arrays for blend shapes.
Returns the format of a mesh's surface.
Returns the primitive type of a mesh's surface.
Returns a mesh's surface's aabb.
Returns the aabb of a mesh's surface's skeleton.
Removes a mesh's surface.
Returns a mesh's number of surfaces.
Sets a mesh's custom aabb.
Returns a mesh's custom aabb.
Removes all surfaces from a mesh.
Creates a new multimesh on the VisualServer and returns an handle. This RID will be used in all multimesh_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
To place in a scene, attach this multimesh to an instance using using the returned RID.
Allocates space for the multimesh data. Format parameters determine how the data will be stored by OpenGL. See , , and for usage. Equivalent to .
Returns the number of instances allocated for this multimesh.
Sets the mesh to be drawn by the multimesh. Equivalent to .
Sets the for this instance. Equivalent to .
Sets the for this instance. For use when multimesh is used in 2D. Equivalent to .
Sets the color by which this instance will be modulated. Equivalent to .
Sets the custom data for this instance. Custom data is passed as a , but is interpreted as a vec4 in the shader. Equivalent to .
Returns the RID of the mesh that will be used in drawing this multimesh.
Calculates and returns the axis-aligned bounding box that encloses all instances within the multimesh.
Returns the of the specified instance.
Returns the of the specified instance. For use when the multimesh is set to use 2D transforms.
Returns the color by which the specified instance will be modulated.
Returns the custom data associated with the specified instance.
Sets the number of instances visible at a given time. If -1, all instances that have been allocated are drawn. Equivalent to .
Returns the number of visible instances for this multimesh.
Sets all data related to the instances in one go. This is especially useful when loading the data from disk or preparing the data from GDNative.
All data is packed in one large float array. An array may look like this: Transform for instance 1, color data for instance 1, custom data for instance 1, transform for instance 2, color data for instance 2, etc.
is stored as 12 floats, is stored as 8 floats, COLOR_8BIT / CUSTOM_DATA_8BIT is stored as 1 float (4 bytes as is) and COLOR_FLOAT / CUSTOM_DATA_FLOAT is stored as 4 floats.
Creates an immediate geometry and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all immediate_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
To place in a scene, attach this immediate geometry to an instance using using the returned RID.
Sets up internals to prepare for drawing. Equivalent to .
Adds the next vertex using the information provided in advance. Equivalent to .
Adds the next vertex using the information provided in advance. This is a helper class that calls under the hood. Equivalent to .
Sets the normal to be used with next vertex. Equivalent to .
Sets the tangent to be used with next vertex. Equivalent to .
Sets the color to be used with next vertex. Equivalent to .
Sets the UV to be used with next vertex. Equivalent to .
Sets the UV2 to be used with next vertex. Equivalent to .
Ends drawing the and displays it. Equivalent to .
Clears everything that was set up between and . Equivalent to .
Sets the material to be used to draw the .
Returns the material assigned to the .
Creates a skeleton and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all skeleton_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Allocates the GPU buffers for this skeleton.
Returns the number of bones allocated for this skeleton.
Sets the for a specific bone of this skeleton.
Returns the set for a specific bone of this skeleton.
Sets the for a specific bone of this skeleton.
Returns the set for a specific bone of this skeleton.
Creates a directional light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID can be used in most light_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
To place in a scene, attach this directional light to an instance using using the returned RID.
Creates a new omni light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID can be used in most light_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
To place in a scene, attach this omni light to an instance using using the returned RID.
Creates a spot light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID can be used in most light_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
To place in a scene, attach this spot light to an instance using using the returned RID.
Sets the color of the light. Equivalent to .
Sets the specified light parameter. See for options. Equivalent to .
If true, light will cast shadows. Equivalent to .
Sets the color of the shadow cast by the light. Equivalent to .
Not implemented in Godot 3.x.
If true, light will subtract light instead of adding light. Equivalent to .
Sets the cull mask for this Light. Lights only affect objects in the selected layers. Equivalent to .
If true, reverses the backface culling of the mesh. This can be useful when you have a flat mesh that has a light behind it. If you need to cast a shadow on both sides of the mesh, set the mesh to use double sided shadows with . Equivalent to .
Sets whether GI probes capture light information from this light. Deprecated method. Use instead. This method is only kept for compatibility reasons and calls internally, setting the bake mode to or depending on the given parameter.
Sets the bake mode for this light, see for options. The bake mode affects how the light will be baked in s and s.
Sets whether to use a dual paraboloid or a cubemap for the shadow map. Dual paraboloid is faster but may suffer from artifacts. Equivalent to .
Sets whether to use vertical or horizontal detail for this omni light. This can be used to alleviate artifacts in the shadow map. Equivalent to .
Sets the shadow mode for this directional light. Equivalent to . See for options.
If true, this directional light will blend between shadow map splits resulting in a smoother transition between them. Equivalent to .
Sets the shadow depth range mode for this directional light. Equivalent to . See for options.
Creates a reflection probe and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all reflection_probe_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
To place in a scene, attach this reflection probe to an instance using using the returned RID.
Sets how often the reflection probe updates. Can either be once or every frame. See for options.
Sets the intensity of the reflection probe. Intensity modulates the strength of the reflection. Equivalent to .
Sets the ambient light color for this reflection probe when set to interior mode. Equivalent to .
Sets the energy multiplier for this reflection probes ambient light contribution when set to interior mode. Equivalent to .
Sets the contribution value for how much the reflection affects the ambient light for this reflection probe when set to interior mode. Useful so that ambient light matches the color of the room. Equivalent to .
Sets the max distance away from the probe an object can be before it is culled. Equivalent to .
Sets the size of the area that the reflection probe will capture. Equivalent to .
Sets the origin offset to be used when this reflection probe is in box project mode. Equivalent to .
If true, reflections will ignore sky contribution. Equivalent to .
If true, uses box projection. This can make reflections look more correct in certain situations. Equivalent to .
If true, computes shadows in the reflection probe. This makes the reflection much slower to compute. Equivalent to .
Sets the render cull mask for this reflection probe. Only instances with a matching cull mask will be rendered by this probe. Equivalent to .
Creates a GI probe and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all gi_probe_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
To place in a scene, attach this GI probe to an instance using using the returned RID.
Sets the axis-aligned bounding box that covers the extent of the GI probe.
Returns the axis-aligned bounding box that covers the full extent of the GI probe.
Sets the size of individual cells within the GI probe.
Returns the cell size set by .
Sets the to cell for this GI probe.
Returns the Transform set by .
Sets the data to be used in the GI probe for lighting calculations. Normally this is created and called internally within the node. You should not try to set this yourself.
Returns the data used by the GI probe.
Sets the dynamic range of the GI probe. Dynamic range sets the limit for how bright lights can be. A smaller range captures greater detail but limits how bright lights can be. Equivalent to .
Returns the dynamic range set for this GI probe. Equivalent to .
Sets the energy multiplier for this GI probe. A higher energy makes the indirect light from the GI probe brighter. Equivalent to .
Returns the energy multiplier for this GI probe. Equivalent to .
Sets the bias value to avoid self-occlusion. Equivalent to .
Returns the bias value for the GI probe. Bias is used to avoid self occlusion. Equivalent to .
Sets the normal bias for this GI probe. Normal bias behaves similar to the other form of bias and may help reduce self-occlusion. Equivalent to .
Returns the normal bias for this GI probe. Equivalent to .
Sets the propagation of light within this GI probe. Equivalent to .
Returns the propagation value for this GI probe. Equivalent to .
Sets the interior value of this GI probe. A GI probe set to interior does not include the sky when calculating lighting. Equivalent to .
Returns true if the GI probe is set to interior, meaning it does not account for sky light. Equivalent to .
Sets the compression setting for the GI probe data. Compressed data will take up less space but may look worse. Equivalent to .
Returns true if the GI probe data associated with this GI probe is compressed. Equivalent to .
Creates a lightmap capture and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all lightmap_capture_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
To place in a scene, attach this lightmap capture to an instance using using the returned RID.
Sets the size of the area covered by the lightmap capture. Equivalent to .
Returns the size of the lightmap capture area.
Sets the octree to be used by this lightmap capture. This function is normally used by the node. Equivalent to .
Sets the octree cell transform for this lightmap capture's octree. Equivalent to .
Returns the cell transform for this lightmap capture's octree.
Sets the subdivision level of this lightmap capture's octree. Equivalent to .
Returns the cell subdivision amount used by this lightmap capture's octree.
Returns the octree used by the lightmap capture.
Sets the energy multiplier for this lightmap capture. Equivalent to .
Returns the energy multiplier used by the lightmap capture.
Sets the "interior" mode for this lightmap capture. Equivalent to .
Returns true if capture is in "interior" mode.
Creates a particle system and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all particles_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
To place in a scene, attach these particles to an instance using using the returned RID.
If true, particles will emit over time. Setting to false does not reset the particles, but only stops their emission. Equivalent to .
Returns true if particles are currently set to emitting.
Sets the number of particles to be drawn and allocates the memory for them. Equivalent to .
Sets the lifetime of each particle in the system. Equivalent to .
If true, particles will emit once and then stop. Equivalent to .
Sets the preprocess time for the particles' animation. This lets you delay starting an animation until after the particles have begun emitting. Equivalent to .
Sets the explosiveness ratio. Equivalent to .
Sets the emission randomness ratio. This randomizes the emission of particles within their phase. Equivalent to .
Sets a custom axis-aligned bounding box for the particle system. Equivalent to .
Sets the speed scale of the particle system. Equivalent to .
If true, particles use local coordinates. If false they use global coordinates. Equivalent to .
Sets the material for processing the particles.
Note: This is not the material used to draw the materials. Equivalent to .
Sets the frame rate that the particle system rendering will be fixed to. Equivalent to .
If true, uses fractional delta which smooths the movement of the particles. Equivalent to .
Returns true if particles are not emitting and particles are set to inactive.
Add particle system to list of particle systems that need to be updated. Update will take place on the next frame, or on the next call to , , or .
Reset the particles on the next update. Equivalent to .
Sets the draw order of the particles to one of the named enums from . See for options. Equivalent to .
Sets the number of draw passes to use. Equivalent to .
Sets the mesh to be used for the specified draw pass. Equivalent to , , , and .
Calculates and returns the axis-aligned bounding box that contains all the particles. Equivalent to .
Sets the that will be used by the particles when they first emit.
Creates a camera and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all camera_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Sets camera to use perspective projection. Objects on the screen becomes smaller when they are far away.
Sets camera to use orthogonal projection, also known as orthographic projection. Objects remain the same size on the screen no matter how far away they are.
Sets camera to use frustum projection. This mode allows adjusting the offset argument to create "tilted frustum" effects.
Sets of camera.
Sets the cull mask associated with this camera. The cull mask describes which 3D layers are rendered by this camera. Equivalent to .
Sets the environment used by this camera. Equivalent to .
If true, preserves the horizontal aspect ratio which is equivalent to . If false, preserves the vertical aspect ratio which is equivalent to .
Creates an empty viewport and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all viewport_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
If true, the viewport uses augmented or virtual reality technologies. See .
Sets the viewport's width and height.
If true, sets the viewport active, else sets it inactive.
Sets the viewport's parent to another viewport.
Copies viewport to a region of the screen specified by rect. If is true, then viewport does not use a framebuffer and the contents of the viewport are rendered directly to screen. However, note that the root viewport is drawn last, therefore it will draw over the screen. Accordingly, you must set the root viewport to an area that does not cover the area that you have attached this viewport to.
For example, you can set the root viewport to not render at all with the following code:
func _ready():
get_viewport().set_attach_to_screen_rect(Rect2())
$Viewport.set_attach_to_screen_rect(Rect2(0, 0, 600, 600))
Using this can result in significant optimization, especially on lower-end devices. However, it comes at the cost of having to manage your viewports manually. For further optimization, see .
If the parameter is null, then the default value is new Rect2(new Vector2(0, 0), new Vector2(0, 0))
If true, render the contents of the viewport directly to screen. This allows a low-level optimization where you can skip drawing a viewport to the root viewport. While this optimization can result in a significant increase in speed (especially on older devices), it comes at a cost of usability. When this is enabled, you cannot read from the viewport or from the SCREEN_TEXTURE. You also lose the benefit of certain window settings, such as the various stretch modes. Another consequence to be aware of is that in 2D the rendering happens in window coordinates, so if you have a viewport that is double the size of the window, and you set this, then only the portion that fits within the window will be drawn, no automatic scaling is possible, even if your game scene is significantly larger than the window size.
Detaches the viewport from the screen.
Sets when the viewport should be updated. See constants for options.
If true, the viewport's rendering is flipped vertically.
Sets the clear mode of a viewport. See for options.
Returns the viewport's last rendered frame.
Currently unimplemented in Godot 3.x.
If true, the viewport's canvas is not rendered.
If true, rendering of a viewport's environment is disabled.
If true, a viewport's 3D rendering is disabled.
Sets a viewport's camera.
Sets a viewport's scenario.
The scenario contains information about the , environment information, reflection atlas etc.
Sets a viewport's canvas.
Detaches a viewport from a canvas and vice versa.
Sets the transformation of a viewport's canvas.
If true, the viewport renders its background as transparent.
Sets the viewport's global transformation matrix.
Sets the stacking order for a viewport's canvas.
layer is the actual canvas layer, while sublayer specifies the stacking order of the canvas among those in the same layer.
Sets the size of the shadow atlas's images (used for omni and spot lights). The value will be rounded up to the nearest power of 2.
Sets the shadow atlas quadrant's subdivision.
Sets the anti-aliasing mode. See for options.
Enables fast approximate antialiasing for this viewport. FXAA is a popular screen-space antialiasing method, which is fast but will make the image look blurry, especially at lower resolutions. It can still work relatively well at large resolutions such as 1440p and 4K. Some of the lost sharpness can be recovered by enabling contrast-adaptive sharpening (see ).
If true, uses a fast post-processing filter to make banding significantly less visible. In some cases, debanding may introduce a slightly noticeable dithering pattern. It's recommended to enable debanding only when actually needed since the dithering pattern will make lossless-compressed screenshots larger.
Note: Only available on the GLES3 backend. must also be true for debanding to be effective.
Sets the sharpening intensity for the viewport. If set to a value greater than 0.0, contrast-adaptive sharpening will be applied to the 3D viewport. This has a low performance cost and can be used to recover some of the sharpness lost from using FXAA. Values around 0.5 generally give the best results. See also .
If true, the viewport renders to high dynamic range (HDR) instead of standard dynamic range (SDR). See also .
Note: Only available on the GLES3 backend.
If true, allocates the viewport's framebuffer with full floating-point precision (32-bit) instead of half floating-point precision (16-bit). Only effective if is used on the same to set HDR to true.
Note: Only available on the GLES3 backend.
Sets the viewport's 2D/3D mode. See constants for options.
Returns a viewport's render information. For options, see the constants.
Sets the debug draw mode of a viewport. See for options.
Creates an environment and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all environment_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Sets the BGMode of the environment. Equivalent to .
Sets the to be used as the environment's background when using BGMode sky. Equivalent to .
Sets a custom field of view for the background . Equivalent to .
Sets the rotation of the background expressed as a . Equivalent to .
Color displayed for clear areas of the scene (if using Custom color or Color+Sky background modes).
Sets the intensity of the background color.
Sets the maximum layer to use if using Canvas background mode.
Sets the ambient light parameters. See for more details.
Sets the values to be used with the "DoF Near Blur" post-process effect. See for more details.
Sets the values to be used with the "DoF Far Blur" post-process effect. See for more details.
Sets the variables to be used with the "glow" post-process effect. See for more details.
Sets the variables to be used with the "tonemap" post-process effect. See for more details.
Sets the values to be used with the "Adjustment" post-process effect. See for more details.
Sets the variables to be used with the "screen space reflections" post-process effect. See for more details.
Sets the variables to be used with the "Screen Space Ambient Occlusion (SSAO)" post-process effect. See for more details.
Sets the variables to be used with the scene fog. See for more details.
Sets the variables to be used with the fog depth effect. See for more details.
Sets the variables to be used with the fog height effect. See for more details.
Creates a scenario and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all scenario_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
The scenario is the 3D world that all the visual instances exist in.
Sets the for this scenario. See for options.
Sets the environment that will be used with this scenario.
Sets the size of the reflection atlas shared by all reflection probes in this scenario.
Sets the fallback environment to be used by this scenario. The fallback environment is used if no environment is set. Internally, this is used by the editor to provide a default environment.
Creates a visual instance, adds it to the VisualServer, and sets both base and scenario. It can be accessed with the RID that is returned. This RID will be used in all instance_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Creates a visual instance and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all instance_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
An instance is a way of placing a 3D object in the scenario. Objects like particles, meshes, and reflection probes need to be associated with an instance to be visible in the scenario using .
Sets the base of the instance. A base can be any of the 3D objects that are created in the VisualServer that can be displayed. For example, any of the light types, mesh, multimesh, immediate geometry, particle system, reflection probe, lightmap capture, and the GI probe are all types that can be set as the base of an instance in order to be displayed in the scenario.
Sets the scenario that the instance is in. The scenario is the 3D world that the objects will be displayed in.
Sets the render layers that this instance will be drawn to. Equivalent to .
Sets the world space transform of the instance. Equivalent to .
Attaches a unique Object ID to instance. Object ID must be attached to instance for proper culling with , , and .
Sets the weight for a given blend shape associated with this instance.
Sets the material of a specific surface. Equivalent to .
Sets whether an instance is drawn or not. Equivalent to .
Sets the lightmap to use with this instance.
If the parameter is null, then the default value is new Rect2(new Vector2(0, 0), new Vector2(1, 1))
Sets a custom AABB to use when culling objects from the view frustum. Equivalent to .
Attaches a skeleton to an instance. Removes the previous skeleton from the instance.
Function not implemented in Godot 3.x.
Sets a margin to increase the size of the AABB when culling objects from the view frustum. This allows you to avoid culling objects that fall outside the view frustum. Equivalent to .
Sets the flag for a given . See for more details.
Sets the shadow casting setting to one of . Equivalent to .
Sets a material that will override the material for all surfaces on the mesh associated with this instance. Equivalent to .
Sets a material that will be rendered for all surfaces on top of active materials for the mesh associated with this instance. Equivalent to .
Not implemented in Godot 3.x.
Not implemented in Godot 3.x.
Returns an array of object IDs intersecting with the provided AABB. Only visual 3D nodes are considered, such as or . Use @GDScript.instance_from_id to obtain the actual nodes. A scenario RID must be provided, which is available in the you want to query. This forces an update for all resources queued to update.
Warning: This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.
Returns an array of object IDs intersecting with the provided 3D ray. Only visual 3D nodes are considered, such as or . Use @GDScript.instance_from_id to obtain the actual nodes. A scenario RID must be provided, which is available in the you want to query. This forces an update for all resources queued to update.
Warning: This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.
Returns an array of object IDs intersecting with the provided convex shape. Only visual 3D nodes are considered, such as or . Use @GDScript.instance_from_id to obtain the actual nodes. A scenario RID must be provided, which is available in the you want to query. This forces an update for all resources queued to update.
Warning: This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.
Creates a canvas and returns the assigned . It can be accessed with the RID that is returned. This RID will be used in all canvas_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
A copy of the canvas item will be drawn with a local offset of the mirroring .
Modulates all colors in the given canvas.
Creates a new and returns its . It can be accessed with the RID that is returned. This RID will be used in all canvas_item_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Sets the parent for the . The parent can be another canvas item, or it can be the root canvas that is attached to the viewport.
Sets if the canvas item (including its children) is visible.
The light mask. See for more information on light masks.
Sets the 's .
Sets clipping for the .
Enables the use of distance fields for GUI elements that are rendering distance field based fonts.
Defines a custom drawing rectangle for the .
If the parameter is null, then the default value is new Rect2(new Vector2(0, 0), new Vector2(0, 0))
Sets the color that modulates the and its children.
Sets the color that modulates the without children.
Sets to be drawn behind its parent.
Adds a line command to the 's draw commands.
Adds a polyline, which is a line from multiple points with a width, to the 's draw commands.
Adds a rectangle to the 's draw commands.
Adds a circle command to the 's draw commands.
Adds a textured rect to the 's draw commands.
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Adds a texture rect with region setting to the 's draw commands.
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Adds a nine patch image to the 's draw commands.
See for more explanation.
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Adds a primitive to the 's draw commands.
Adds a polygon to the 's draw commands.
If the parameter is null, then the default value is Array.Empty<Vector2>()
Adds a triangle array to the 's draw commands.
If the parameter is null, then the default value is Array.Empty<Vector2>()
If the parameter is null, then the default value is Array.Empty<int>()
If the parameter is null, then the default value is Array.Empty<float>()
Adds a mesh command to the 's draw commands.
If the parameter is null, then the default value is Transform2D.Identity
If the parameter is null, then the default value is new Color(1, 1, 1, 1)
Adds a to the 's draw commands. Only affects its aabb at the moment.
Adds a particle system to the 's draw commands.
Adds a command to the 's draw commands.
This sets the extra_matrix uniform when executed. This affects the later commands of the canvas item.
If ignore is true, the VisualServer does not perform clipping.
Sets if 's children should be sorted by y-position.
Sets the 's Z index, i.e. its draw order (lower indexes are drawn first).
If this is enabled, the Z index of the parent will be added to the children's Z index.
Sets the to copy a rect to the backbuffer.
Clears the and removes all commands in it.
Sets the index for the .
Sets a new material to the .
Sets if the uses its parent's material.
Creates a canvas light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all canvas_light_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Attaches the canvas light to the canvas. Removes it from its previous canvas.
Enables or disables a canvas light.
Sets the texture's scale factor of the light. Equivalent to .
Sets the canvas light's .
Sets texture to be used by light. Equivalent to .
Sets the offset of the light's texture. Equivalent to .
Sets the color for a light.
Sets a canvas light's height.
Sets a canvas light's energy.
Sets the Z range of objects that will be affected by this light. Equivalent to and .
The layer range that gets rendered with this light.
The light mask. See for more information on light masks.
The binary mask used to determine which layers this canvas light's shadows affects. See for more information on light masks.
The mode of the light, see constants.
Enables or disables the canvas light's shadow.
Sets the width of the shadow buffer, size gets scaled to the next power of two for this.
Sets the length of the shadow's gradient.
Sets the canvas light's shadow's filter, see constants.
Sets the color of the canvas light's shadow.
Smoothens the shadow. The lower, the smoother.
Creates a light occluder and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all canvas_light_ocluder_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Attaches a light occluder to the canvas. Removes it from its previous canvas.
Enables or disables light occluder.
Sets a light occluder's polygon.
Sets a light occluder's .
The light mask. See for more information on light masks.
Creates a new light occluder polygon and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all canvas_occluder_polygon_* VisualServer functions.
Once finished with your RID, you will want to free the RID using the VisualServer's static method.
Sets the shape of the occluder polygon.
Sets the shape of the occluder polygon as lines.
Sets an occluder polygons cull mode. See constants.
Sets margin size, where black bars (or images, if was used) are rendered.
Sets images to be rendered in the window margin.
Tries to free an object in the VisualServer.
Schedules a callback to the corresponding named method on where after a frame has been drawn.
The callback method must use only 1 argument which will be called with userdata.
Returns true if changes have been made to the VisualServer's data. is usually called if this happens.
As changes are registered as either high or low priority (e.g. dynamic shaders), this function takes an optional argument to query either low or high priority changes, or any changes.
Initializes the visual server. This function is called internally by platform-dependent code during engine initialization. If called from a running game, it will not do anything.
Removes buffers and clears testcubes.
Returns a certain information, see for options.
Returns the name of the video adapter (e.g. "GeForce GTX 1080/PCIe/SSE2").
Note: When running a headless or server binary, this function returns an empty string.
Returns the vendor of the video adapter (e.g. "NVIDIA Corporation").
Note: When running a headless or server binary, this function returns an empty string.
Returns a mesh of a sphere with the given amount of horizontal and vertical subdivisions.
Returns the id of the test cube. Creates one if none exists.
Returns the id of the test texture. Creates one if none exists.
Returns the id of a white texture. Creates one if none exists.
Sets a boot image. The color defines the background color. If scale is true, the image will be scaled to fit the screen size. If use_filter is true, the image will be scaled with linear interpolation. If use_filter is false, the image will be scaled with nearest-neighbor interpolation.
Sets the default clear color which is used when a specific clear color has not been selected.
Sets the scale to apply to the passage of time for the shaders' TIME builtin.
The default value is 1.0, which means TIME will count the real time as it goes by, without narrowing or stretching it.
Not yet implemented. Always returns false.
Returns true if the OS supports a certain feature. Features might be s3tc, etc, etc2, pvrtc and skinning_fallback.
When rendering with GLES2, returns true with skinning_fallback in case the hardware doesn't support the default GPU skinning process.
If true, the engine will generate wireframes for use with the wireframe debug mode.
Enables or disables occlusion culling.
This class allows you to define a custom shader program that can be used for various materials to render objects.
The visual shader editor creates the shader.
A vertex shader, operating on vertices.
A fragment shader, operating on fragments (pixels).
A shader for light calculations.
Represents the size of the enum.
The offset vector of the whole graph.
Sets the mode of this shader.
Adds the specified node to the shader.
Returns the shader node instance with specified type and id.
Sets the position of the specified node.
Returns the position of the specified node within the shader graph.
Returns the list of all nodes in the shader with the specified type.
Removes the specified node from the shader.
Returns true if the specified node and port connection exist.
Returns true if the specified nodes and ports can be connected together.
Connects the specified nodes and ports.
Connects the specified nodes and ports.
Connects the specified nodes and ports, even if they can't be connected. Such connection is invalid and will not function properly.
Returns the list of connected nodes with the specified type.
Visual shader graphs consist of various nodes. Each node in the graph is a separate object and they are represented as a rectangular boxes with title and a set of properties. Each node has also connection ports that allow to connect it to another nodes and control the flow of the shader.
Floating-point scalar. Translated to float type in shader code.
3D vector of floating-point values. Translated to vec3 type in shader code.
Boolean type. Translated to bool type in shader code.
Transform type. Translated to mat4 type in shader code.
Sampler type. Translated to reference of sampler uniform in shader code. Can only be used for input ports in non-uniform nodes.
Represents the size of the enum.
Sets the output port index which will be showed for preview. If set to -1 no port will be open for preview.
Sets the default value for the selected input port.
Returns the default value of the input port.
Sets the default input ports values using an of the form [index0, value0, index1, value1, ...]. For example: [0, Vector3(0, 0, 0), 1, Vector3(0, 0, 0)].
Returns an containing default values for all of the input ports of the node in the form [index0, value0, index1, value1, ...].
Has only one output port and no inputs.
Translated to bool in the shader language.
A boolean constant which represents a state of this node.
Translated to uniform bool in the shader language.
Enables usage of the .
A default value to be assigned within the shader.
Has two output ports representing RGB and alpha channels of .
Translated to vec3 rgb and float alpha in the shader language.
A constant which represents a state of this node.
Accept a to the input port and transform it according to .
Converts the color to grayscale using the following formula:
vec3 c = input;
float max1 = max(c.r, c.g);
float max2 = max(max1, c.b);
float max3 = max(max1, max2);
return vec3(max3, max3, max3);
Applies sepia tone effect using the following formula:
vec3 c = input;
float r = (c.r * 0.393) + (c.g * 0.769) + (c.b * 0.189);
float g = (c.r * 0.349) + (c.g * 0.686) + (c.b * 0.168);
float b = (c.r * 0.272) + (c.g * 0.534) + (c.b * 0.131);
return vec3(r, g, b);
A function to be applied to the input color. See for options.
Applies to two color inputs.
Produce a screen effect with the following formula:
result = vec3(1.0) - (vec3(1.0) - a) * (vec3(1.0) - b);
Produce a difference effect with the following formula:
result = abs(a - b);
Produce a darken effect with the following formula:
result = min(a, b);
Produce a lighten effect with the following formula:
result = max(a, b);
Produce an overlay effect with the following formula:
for (int i = 0; i < 3; i++) {
float base = a[i];
float blend = b[i];
if (base < 0.5) {
result[i] = 2.0 * base * blend;
} else {
result[i] = 1.0 - 2.0 * (1.0 - blend) * (1.0 - base);
}
}
Produce a dodge effect with the following formula:
result = a / (vec3(1.0) - b);
Produce a burn effect with the following formula:
result = vec3(1.0) - (vec3(1.0) - a) / b;
Produce a soft light effect with the following formula:
for (int i = 0; i < 3; i++) {
float base = a[i];
float blend = b[i];
if (base < 0.5) {
result[i] = base * (blend + 0.5);
} else {
result[i] = 1.0 - (1.0 - base) * (1.0 - (blend - 0.5));
}
}
Produce a hard light effect with the following formula:
for (int i = 0; i < 3; i++) {
float base = a[i];
float blend = b[i];
if (base < 0.5) {
result[i] = base * (2.0 * blend);
} else {
result[i] = 1.0 - (1.0 - base) * (1.0 - 2.0 * (blend - 0.5));
}
}
An operator to be applied to the inputs. See for options.
Translated to uniform vec4 in the shader language.
Enables usage of the .
A default value to be assigned within the shader.
Compares a and b of by . Returns a boolean scalar. Translates to if instruction in shader code.
A floating-point scalar.
A 3D vector type.
A boolean type.
A transform (mat4) type.
Comparison for equality (a == b).
Comparison for inequality (a != b).
Comparison for greater than (a > b). Cannot be used if set to or .
Comparison for greater than or equal (a >= b). Cannot be used if set to or .
Comparison for less than (a < b). Cannot be used if set to or .
Comparison for less than or equal (a < b). Cannot be used if set to or .
The result will be true if all of component in vector satisfy the comparison condition.
The result will be true if any of component in vector satisfy the comparison condition.
The type to be used in the comparison. See for options.
A comparison function. See for options.
Extra condition which is applied if is set to .
Translated to texture(cubemap, vec3) in the shader language. Returns a color vector and alpha channel as scalar.
No hints are added to the uniform declaration.
Adds hint_albedo as hint to the uniform declaration for proper sRGB to linear conversion.
Adds hint_normal as hint to the uniform declaration, which internally converts the texture for proper usage as normal map.
Use the set via . If this is set to , the samplerCube port is ignored.
Use the sampler reference passed via the samplerCube port. If this is set to , the texture is ignored.
Defines which source should be used for the sampling. See for options.
The texture to sample when using as .
Defines the type of data provided by the source texture. See for options.
Translated to uniform samplerCube in the shader language. The output value can be used as port for .
By inheriting this class you can create a custom script addon which will be automatically added to the Visual Shader Editor. The 's behavior is defined by overriding the provided virtual methods.
In order for the node to be registered as an editor addon, you must use the tool keyword and provide a class_name for your custom script. For example:
tool
extends VisualShaderNodeCustom
class_name VisualShaderNodeNoise
Override this method to define the category of the associated custom node in the Visual Shader Editor's members dialog. The path may look like "MyGame/MyFunctions/Noise".
Defining this method is optional. If not overridden, the node will be filed under the "Custom" category.
Override this method to define the actual shader code of the associated custom node. The shader code should be returned as a string, which can have multiple lines (the """ multiline string construct can be used for convenience).
The input_vars and output_vars arrays contain the string names of the various input and output variables, as defined by _get_input_* and _get_output_* virtual methods in this class.
The output ports can be assigned values in the shader code. For example, return output_vars[0] + " = " + input_vars[0] + ";".
You can customize the generated code based on the shader mode (see ) and/or type (see ).
Defining this method is required.
Override this method to define the description of the associated custom node in the Visual Shader Editor's members dialog.
Defining this method is optional.
Override this method to add shader code on top of the global shader, to define your own standard library of reusable methods, varyings, constants, uniforms, etc. The shader code should be returned as a string, which can have multiple lines (the """ multiline string construct can be used for convenience).
Be careful with this functionality as it can cause name conflicts with other custom nodes, so be sure to give the defined entities unique names.
You can customize the generated code based on the shader mode (see ).
Defining this method is optional.
Override this method to define the amount of input ports of the associated custom node.
Defining this method is required. If not overridden, the node has no input ports.
Override this method to define the names of input ports of the associated custom node. The names are used both for the input slots in the editor and as identifiers in the shader code, and are passed in the input_vars array in .
Defining this method is optional, but recommended. If not overridden, input ports are named as "in" + str(port).
Override this method to define the returned type of each input port of the associated custom node (see for possible types).
Defining this method is optional, but recommended. If not overridden, input ports will return the type.
Override this method to define the name of the associated custom node in the Visual Shader Editor's members dialog and graph.
Defining this method is optional, but recommended. If not overridden, the node will be named as "Unnamed".
Override this method to define the amount of output ports of the associated custom node.
Defining this method is required. If not overridden, the node has no output ports.
Override this method to define the names of output ports of the associated custom node. The names are used both for the output slots in the editor and as identifiers in the shader code, and are passed in the output_vars array in .
Defining this method is optional, but recommended. If not overridden, output ports are named as "out" + str(port).
Override this method to define the returned type of each output port of the associated custom node (see for possible types).
Defining this method is optional, but recommended. If not overridden, output ports will return the type.
Override this method to define the return icon of the associated custom node in the Visual Shader Editor's members dialog.
Defining this method is optional. If not overridden, no return icon is shown.
Override this method to define the subcategory of the associated custom node in the Visual Shader Editor's members dialog.
Defining this method is optional. If not overridden, the node will be filed under the root of the main category (see ).
Translates to determinant(x) in the shader language.
Translates to dot(a, b) in the shader language.
Custom Godot Shading Language expression, with a custom amount of input and output ports.
The provided code is directly injected into the graph's matching shader function (vertex, fragment, or light), so it cannot be used to declare functions, varyings, uniforms, or global constants. See for such global definitions.
An expression in Godot Shading Language, which will be injected at the start of the graph's matching shader function (vertex, fragment, or light), and thus cannot be used to declare functions, varyings, uniforms, or global constants.
Translates to faceforward(N, I, Nref) in the shader language. The function has three vector parameters: N, the vector to orient, I, the incident vector, and Nref, the reference vector. If the dot product of I and Nref is smaller than zero the return value is N. Otherwise, -N is returned.
Returns falloff based on the dot product of surface normal and view direction of camera (pass associated inputs to it).
Custom Godot Shader Language expression, which is placed on top of the generated shader. You can place various function definitions inside to call later in s (which are injected in the main shader functions). You can also declare varyings, uniforms and global constants.
Currently, has no direct usage, use the derived classes instead.
The size of the node in the visual shader graph.
Defines all input ports using a formatted as a colon-separated list: id,type,name; (see ).
Returns a description of the input ports as a colon-separated list using the format id,type,name; (see ).
Defines all output ports using a formatted as a colon-separated list: id,type,name; (see ).
Returns a description of the output ports as a colon-separated list using the format id,type,name; (see ).
Returns true if the specified port name does not override an existed port name and is valid within the shader.
Adds an input port with the specified type (see ) and name.
Removes the specified input port.
Returns the number of input ports in use. Alternative for .
Returns true if the specified input port exists.
Removes all previously specified input ports.
Adds an output port with the specified type (see ) and name.
Removes the specified output port.
Returns the number of output ports in use. Alternative for .
Returns true if the specified output port exists.
Removes all previously specified output ports.
Renames the specified input port.
Sets the specified input port's type (see ).
Renames the specified output port.
Sets the specified output port's type (see ).
Returns a free input port ID which can be used in .
Returns a free output port ID which can be used in .
Gives access to input variables (built-ins) available for the shader. See the shading reference for the list of available built-ins for each shader type (check Tutorials section for link).
One of the several input constants in lower-case style like: "vertex"(VERTEX) or "point_size"(POINT_SIZE).
Returns the boolean result of the comparison between INF or NaN and a scalar parameter.
Comparison with INF (Infinity).
Comparison with NaN (Not a Number; denotes invalid numeric results, e.g. division by zero).
The comparison function. See for options.
OuterProduct treats the first parameter c as a column vector (matrix with one column) and the second parameter r as a row vector (matrix with one row) and does a linear algebraic matrix multiply c * r, yielding a matrix whose number of rows is the number of components in c and whose number of columns is the number of components in r.
This visual shader node is present in all shader graphs in form of "Output" block with multiple output value ports.
Constrains a value to lie between min and max values.
This node is only available in Fragment and Light visual shaders.
Sum of absolute derivative in x and y.
Derivative in x using local differencing.
Derivative in y using local differencing.
The derivative type. See for options.
Translates to mix(a, b, weight) in the shader language.
Translates to smoothstep(edge0, edge1, x) in the shader language.
Returns 0.0 if x is smaller than edge0 and 1.0 if x is larger than edge1. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials.
Returns an associated scalar if the provided boolean value is true or false.
No hint used.
A range hint for scalar value, which limits possible input values between and . Translated to hint_range(min, max) in shader code.
A range hint for scalar value with step, which limits possible input values between and , with a step (increment) of ). Translated to hint_range(min, max, step) in shader code.
Represents the size of the enum.
A hint applied to the uniform, which controls the values it can take when set through the inspector.
Maximum value for range hints. Used if is set to or .
Minimum value for range hints. Used if is set to or .
Step (increment) value for the range hint with step. Used if is set to .
Enables usage of the .
A default value to be assigned within the shader.
Returns an associated vector if the provided boolean value is true or false.
Performs a lookup operation on the provided texture, with support for multiple texture sources to choose from.
No hints are added to the uniform declaration.
Adds hint_albedo as hint to the uniform declaration for proper sRGB to linear conversion.
Adds hint_normal as hint to the uniform declaration, which internally converts the texture for proper usage as normal map.
Use the texture given as an argument for this function.
Use the current viewport's texture as the source.
Use the texture from this shader's texture built-in (e.g. a texture of a ).
Use the texture from this shader's normal map built-in.
Use the depth texture available for this shader.
Use the texture provided in the input port for this function.
Determines the source for the lookup. See for options.
The source texture, if needed for the selected .
Specifies the type of the texture if is set to . See for options.
Performs a lookup operation on the texture provided as a uniform for the shader.
No hints are added to the uniform declaration.
Adds hint_albedo as hint to the uniform declaration for proper sRGB to linear conversion.
Adds hint_normal as hint to the uniform declaration, which internally converts the texture for proper usage as normal map.
Adds hint_aniso as hint to the uniform declaration to use for a flowmap.
Defaults to white color.
Defaults to black color.
Defines the type of data provided by the source texture. See for options.
Sets the default color if no texture is assigned to the uniform.
Performs a lookup operation on the texture provided as a uniform for the shader, with support for triplanar mapping.
Creates a 4x4 transform matrix using four vectors of type vec3. Each vector is one row in the matrix and the last column is a vec4(0, 0, 0, 1).
A constant , which can be used as an input node.
A constant which represents the state of this node.
Takes a 4x4 transform matrix and decomposes it into four vec3 values, one from each row of the matrix.
Computes an inverse or transpose function on the provided .
Perform the inverse operation on the matrix.
Perform the transpose operation on the matrix.
The function to be computed. See for options.
A multiplication operation on two transforms (4x4 matrices), with support for different multiplication operators.
Multiplies transform a by the transform b.
Multiplies transform b by the transform a.
Performs a component-wise multiplication of transform a by the transform b.
Performs a component-wise multiplication of transform b by the transform a.
The multiplication type to be performed on the transforms. See for options.
Translated to uniform mat4 in the shader language.
Enables usage of the .
A default value to be assigned within the shader.
A multiplication operation on a transform (4x4 matrix) and a vector, with support for different multiplication operators.
Multiplies transform a by the vector b.
Multiplies vector b by the transform a.
Multiplies transform a by the vector b, skipping the last row and column of the transform.
Multiplies vector b by the transform a, skipping the last row and column of the transform.
The multiplication type to be performed. See for options.
A uniform represents a variable in the shader which is set externally, i.e. from the . Uniforms are exposed as properties in the and can be assigned from the inspector or from a script.
Name of the uniform, by which it can be accessed through the properties.
Creating a reference to a allows you to reuse this uniform in different shaders or shader stages easily.
The name of the uniform which this reference points to.
A constant , which can be used as an input node.
A constant which represents the state of this node.
Translated to uniform vec3 in the shader language.
Enables usage of the .
A default value to be assigned within the shader.
Constrains a value to lie between min and max values. The operation is performed on each component of the vector individually.
Creates a vec3 using three scalar values that can be provided from separate inputs.
Takes a vec3 and decomposes it into three scalar values that can be used as separate inputs.
This node is only available in Fragment and Light visual shaders.
Sum of absolute derivative in x and y.
Derivative in x using local differencing.
Derivative in y using local differencing.
A derivative type. See for options.
Calculates distance from point represented by vector p0 to vector p1.
Translated to distance(p0, p1) in the shader language.
A visual shader node able to perform different functions using vectors.
Normalizes the vector so that it has a length of 1 but points in the same direction.
Clamps the value between 0.0 and 1.0.
Returns the opposite value of the parameter.
Returns 1/vector.
Converts RGB vector to HSV equivalent.
Converts HSV vector to RGB equivalent.
Returns the absolute value of the parameter.
Returns the arc-cosine of the parameter.
Returns the inverse hyperbolic cosine of the parameter.
Returns the arc-sine of the parameter.
Returns the inverse hyperbolic sine of the parameter.
Returns the arc-tangent of the parameter.
Returns the inverse hyperbolic tangent of the parameter.
Finds the nearest integer that is greater than or equal to the parameter.
Returns the cosine of the parameter.
Returns the hyperbolic cosine of the parameter.
Converts a quantity in radians to degrees.
Base-e Exponential.
Base-2 Exponential.
Finds the nearest integer less than or equal to the parameter.
Computes the fractional part of the argument.
Returns the inverse of the square root of the parameter.
Natural logarithm.
Base-2 logarithm.
Converts a quantity in degrees to radians.
Finds the nearest integer to the parameter.
Finds the nearest even integer to the parameter.
Extracts the sign of the parameter, i.e. returns -1 if the parameter is negative, 1 if it's positive and 0 otherwise.
Returns the sine of the parameter.
Returns the hyperbolic sine of the parameter.
Returns the square root of the parameter.
Returns the tangent of the parameter.
Returns the hyperbolic tangent of the parameter.
Returns a value equal to the nearest integer to the parameter whose absolute value is not larger than the absolute value of the parameter.
Returns 1.0 - vector.
The function to be performed. See for options.
Translates to mix(a, b, weight) in the shader language, where weight is a with weights for each component.
Translated to length(p0) in the shader language.
A visual shader node for use of vector operators. Operates on vector a and vector b.
Adds two vectors.
Subtracts a vector from a vector.
Multiplies two vectors.
Divides vector by vector.
Returns the remainder of the two vectors.
Returns the value of the first parameter raised to the power of the second, for each component of the vectors.
Returns the greater of two values, for each component of the vectors.
Returns the lesser of two values, for each component of the vectors.
Calculates the cross product of two vectors.
Returns the arc-tangent of the parameters.
Returns the vector that points in the direction of reflection. a is incident vector and b is the normal vector.
Vector step operator. Returns 0.0 if a is smaller than b and 1.0 otherwise.
The operator to be used. See for options.
Translated to refract(I, N, eta) in the shader language, where I is the incident vector, N is the normal vector and eta is the ratio of the indices of the refraction.
Translates to mix(a, b, weight) in the shader language, where a and b are vectors and weight is a scalar.
Translates to smoothstep(edge0, edge1, x) in the shader language, where x is a scalar.
Returns 0.0 if x is smaller than edge0 and 1.0 if x is larger than edge1. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials.
Translates to step(edge, x) in the shader language.
Returns 0.0 if x is smaller than edge and 1.0 otherwise.
Translates to smoothstep(edge0, edge1, x) in the shader language, where x is a vector.
Returns 0.0 if x is smaller than edge0 and 1.0 if x is larger than edge1. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials.
A weakref can hold a , without contributing to the reference counter. A weakref can be created from an using @GDScript.weakref. If this object is not a reference, weakref still works, however, it does not have any effect on the object. Weakrefs are useful in cases where multiple classes have variables that refer to each other. Without weakrefs, using these classes could lead to memory leaks, since both references keep each other from being released. Making part of the variables a weakref can prevent this cyclic dependency, and allows the references to be released.
Returns the this weakref is referring to. Returns null if that object no longer exists.
Tells the channel to send data over this channel as text. An external peer (non-Godot) would receive this as a string.
Tells the channel to send data over this channel as binary. An external peer (non-Godot) would receive this as array buffer or blob.
The channel was created, but it's still trying to connect.
The channel is currently open, and data can flow over it.
The channel is being closed, no new messages will be accepted, but those already in queue will be flushed.
The channel was closed, or connection failed.
The transfer mode to use when sending outgoing packet. Either text or binary.
Reserved, but not used for now.
Closes this data channel, notifying the other peer.
Returns true if the last received packet was transferred as text. See .
Returns the current state of this channel, see .
Returns the label assigned to this channel during creation.
Returns true if this channel was created with ordering enabled (default).
Returns the id assigned to this channel during creation (or auto-assigned during negotiation).
If the channel is not negotiated out-of-band the id will only be available after the connection is established (will return 65535 until then).
Returns the maxPacketLifeTime value assigned to this channel during creation.
Will be 65535 if not specified.
Returns the maxRetransmits value assigned to this channel during creation.
Will be 65535 if not specified.
Returns the sub-protocol assigned to this channel during creation. An empty string if not specified.
Returns true if this channel was created with out-of-band configuration.
Returns the number of bytes currently queued to be sent over this channel.
This class constructs a full mesh of (one connection for each peer) that can be used as a .
You can add each via or remove them via . Peers must be added in state to allow it to create the appropriate channels. This class will not create offers nor set descriptions, it will only poll them, and notify connections and disconnections.
NetworkedMultiplayerPeer.connection_succeeded and NetworkedMultiplayerPeer.server_disconnected will not be emitted unless server_compatibility is true in . Beside that data transfer works like in a .
Initialize the multiplayer peer with the given peer_id (must be between 1 and 2147483647).
If server_compatibilty is false (default), the multiplayer peer will be immediately in state and NetworkedMultiplayerPeer.connection_succeeded will not be emitted.
If server_compatibilty is true the peer will suppress all NetworkedMultiplayerPeer.peer_connected signals until a peer with id connects and then emit NetworkedMultiplayerPeer.connection_succeeded. After that the signal NetworkedMultiplayerPeer.peer_connected will be emitted for every already connected peer, and any new peer that might connect. If the server peer disconnects after that, signal NetworkedMultiplayerPeer.server_disconnected will be emitted and state will become .
Add a new peer to the mesh with the given peer_id. The must be in state .
Three channels will be created for reliable, unreliable, and ordered transport. The value of unreliable_lifetime will be passed to the maxPacketLifetime option when creating unreliable and ordered channels (see ).
Remove the peer with given peer_id from the mesh. If the peer was connected, and NetworkedMultiplayerPeer.peer_connected was emitted for it, then NetworkedMultiplayerPeer.peer_disconnected will be emitted.
Returns true if the given peer_id is in the peers map (it might not be connected though).
Return a dictionary representation of the peer with given peer_id with three keys. connection containing the to this peer, channels an array of three , and connected a boolean representing if the peer connection is currently connected (all three channels are open).
Returns a dictionary which keys are the peer ids and values the peer representation as in .
Close all the add peer connections and channels, freeing all resources.
A WebRTC connection between the local computer and a remote peer. Provides an interface to connect, maintain and monitor the connection.
Setting up a WebRTC connection between two peers from now on) may not seem a trivial task, but it can be broken down into 3 main steps:
- The peer that wants to initiate the connection (A from now on) creates an offer and send it to the other peer (B from now on).
- B receives the offer, generate and answer, and sends it to A).
- A and B then generates and exchange ICE candidates with each other.
After these steps, the connection should become connected. Keep on reading or look into the tutorial for more information.
The connection is new, data channels and an offer can be created in this state.
The peer is connecting, ICE is in progress, none of the transports has failed.
The peer is connected, all ICE transports are connected.
At least one ICE transport is disconnected.
One or more of the ICE transports failed.
The peer connection is closed (after calling for example).
Re-initialize this peer connection, closing any previously active connection, and going back to state . A dictionary of options can be passed to configure the peer connection.
Valid options are:
{
"iceServers": [
{
"urls": [ "stun:stun.example.com:3478" ], # One or more STUN servers.
},
{
"urls": [ "turn:turn.example.com:3478" ], # One or more TURN servers.
"username": "a_username", # Optional username for the TURN server.
"credential": "a_password", # Optional password for the TURN server.
}
]
}
If the parameter is null, then the default value is new Godot.Collections.Dictionary()
Returns a new (or null on failure) with given label and optionally configured via the options dictionary. This method can only be called when the connection is in state .
There are two ways to create a working data channel: either call on only one of the peer and listen to data_channel_received on the other, or call on both peers, with the same values, and the negotiated option set to true.
Valid options are:
{
"negotiated": true, # When set to true (default off), means the channel is negotiated out of band. "id" must be set too. "data_channel_received" will not be called.
"id": 1, # When "negotiated" is true this value must also be set to the same value on both peer.
# Only one of maxRetransmits and maxPacketLifeTime can be specified, not both. They make the channel unreliable (but also better at real time).
"maxRetransmits": 1, # Specify the maximum number of attempt the peer will make to retransmits packets if they are not acknowledged.
"maxPacketLifeTime": 100, # Specify the maximum amount of time before giving up retransmitions of unacknowledged packets (in milliseconds).
"ordered": true, # When in unreliable mode (i.e. either "maxRetransmits" or "maxPacketLifetime" is set), "ordered" (true by default) specify if packet ordering is to be enforced.
"protocol": "my-custom-protocol", # A custom sub-protocol string for this channel.
}
Note: You must keep a reference to channels created this way, or it will be closed.
If the parameter is null, then the default value is new Godot.Collections.Dictionary()
Creates a new SDP offer to start a WebRTC connection with a remote peer. At least one must have been created before calling this method.
If this functions returns OK, session_description_created will be called when the session is ready to be sent.
Sets the SDP description of the local peer. This should be called in response to session_description_created.
After calling this function the peer will start emitting ice_candidate_created (unless an different from OK is returned).
Sets the SDP description of the remote peer. This should be called with the values generated by a remote peer and received over the signaling server.
If type is offer the peer will emit session_description_created with the appropriate answer.
If type is answer the peer will start emitting ice_candidate_created.
Add an ice candidate generated by a remote peer (and received over the signaling server). See ice_candidate_created.
Call this method frequently (e.g. in or ) to properly receive signals.
Close the peer connection and all data channels associated with it.
Note: You cannot reuse this object for a new connection unless you call .
Returns the connection state. See .
This class implements a WebSocket client compatible with any RFC 6455-compliant WebSocket server.
This client can be optionally used as a network peer for the .
After starting the client (), you will need to it at regular intervals (e.g. inside ).
You will receive appropriate signals when connecting, disconnecting, or when new data is available.
If true, SSL certificate verification is enabled.
Note: You must specify the certificates to be used in the Project Settings for it to work when exported.
If specified, this will be the only one accepted when connecting to an SSL host. Any other certificate provided by the server will be regarded as invalid.
Note: Specifying a custom trusted_ssl_certificate is not supported in HTML5 exports due to browsers restrictions.
Connects to the given URL requesting one of the given protocols as sub-protocol. If the list empty (default), no sub-protocol will be requested.
If true is passed as gd_mp_api, the client will behave like a network peer for the , connections to non-Godot servers will not work, and data_received will not be emitted.
If false is passed instead (default), you must call functions (put_packet, get_packet, etc.) on the returned via get_peer(1) and not on this object directly (e.g. get_peer(1).put_packet(data)).
You can optionally pass a list of custom_headers to be added to the handshake HTTP request.
Note: To avoid mixed content warnings or errors in HTML5, you may have to use a url that starts with wss:// (secure) instead of ws://. When doing so, make sure to use the fully qualified domain name that matches the one defined in the server's SSL certificate. Do not connect directly via the IP address for wss:// connections, as it won't match with the SSL certificate.
Note: Specifying custom_headers is not supported in HTML5 exports due to browsers restrictions.
If the parameter is null, then the default value is Array.Empty<string>()
If the parameter is null, then the default value is Array.Empty<string>()
Disconnects this client from the connected host. See for more information.
Return the IP address of the currently connected host.
Return the IP port of the currently connected host.
Base class for WebSocket server and client, allowing them to be used as network peer for the .
Configures the buffer sizes for this WebSocket peer. Default values can be specified in the Project Settings under network/limits. For server, values are meant per connected peer.
The first two parameters define the size and queued packets limits of the input buffer, the last two of the output buffer.
Buffer sizes are expressed in KiB, so 4 = 2^12 = 4096 bytes. All parameters will be rounded up to the nearest power of two.
Note: HTML5 exports only use the input buffer since the output one is managed by browsers.
Returns the associated to the given peer_id.
This class represents a specific WebSocket connection, allowing you to do lower level operations with it.
You can choose to write to the socket in binary or text mode, and you can recognize the mode used for writing by the other peer.
Specifies that WebSockets messages should be transferred as text payload (only valid UTF-8 is allowed).
Specifies that WebSockets messages should be transferred as binary payload (any byte combination is allowed).
Gets the current selected write mode. See .
Sets the socket to use the given .
Returns true if this peer is currently connected.
Returns true if the last received packet was sent as a text payload. See .
Closes this WebSocket connection. code is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). reason is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes).
Note: To achieve a clean close, you will need to keep polling until either WebSocketClient.connection_closed or WebSocketServer.client_disconnected is received.
Note: The HTML5 export might not support all status codes. Please refer to browser-specific documentation for more details.
Returns the IP address of the connected peer.
Note: Not available in the HTML5 export.
Returns the remote port of the connected peer.
Note: Not available in the HTML5 export.
Disable Nagle's algorithm on the underling TCP socket (default). See for more information.
Note: Not available in the HTML5 export.
Returns the current amount of data in the outbound websocket buffer. Note: HTML5 exports use WebSocket.bufferedAmount, while other platforms use an internal buffer.
This class implements a WebSocket server that can also support the high-level multiplayer API.
After starting the server (), you will need to it at regular intervals (e.g. inside ). When clients connect, disconnect, or send data, you will receive the appropriate signal.
Note: Not available in HTML5 exports.
When not set to * will restrict incoming connections to the specified IP address. Setting bind_ip to 127.0.0.1 will cause the server to listen only to the local host.
When set to a valid (along with ) will cause the server to require SSL instead of regular TCP (i.e. the wss:// protocol).
When set to a valid (along with ) will cause the server to require SSL instead of regular TCP (i.e. the wss:// protocol).
When using SSL (see and ), you can set this to a valid to be provided as additional CA chain information during the SSL handshake.
The time in seconds before a pending client (i.e. a client that has not yet finished the HTTP handshake) is considered stale and forcefully disconnected.
Returns true if the server is actively listening on a port.
Sets additional headers to be sent to clients during the HTTP handshake.
If the parameter is null, then the default value is Array.Empty<string>()
Starts listening on the given port.
You can specify the desired subprotocols via the "protocols" array. If the list empty (default), no sub-protocol will be requested.
If true is passed as gd_mp_api, the server will behave like a network peer for the , connections from non-Godot clients will not work, and data_received will not be emitted.
If false is passed instead (default), you must call functions (put_packet, get_packet, etc.), on the returned via get_peer(id) to communicate with the peer with given id (e.g. get_peer(id).get_available_packet_count).
If the parameter is null, then the default value is Array.Empty<string>()
Stops the server and clear its state.
Returns true if a peer with the given ID is connected.
Returns the IP address of the given peer.
Returns the remote port of the given peer.
Disconnects the peer identified by id from the server. See for more information.
WebXR is an open standard that allows creating VR and AR applications that run in the web browser.
As such, this interface is only available when running in an HTML5 export.
WebXR supports a wide range of devices, from the very capable (like Valve Index, HTC Vive, Oculus Rift and Quest) down to the much less capable (like Google Cardboard, Oculus Go, GearVR, or plain smartphones).
Since WebXR is based on Javascript, it makes extensive use of callbacks, which means that is forced to use signals, where other AR/VR interfaces would instead use functions that return a result immediately. This makes quite a bit more complicated to initialize than other AR/VR interfaces.
Here's the minimum code required to start an immersive VR session:
extends Spatial
var webxr_interface
var vr_supported = false
func _ready():
# We assume this node has a button as a child.
# This button is for the user to consent to entering immersive VR mode.
$Button.connect("pressed", self, "_on_Button_pressed")
webxr_interface = ARVRServer.find_interface("WebXR")
if webxr_interface:
# Map to the standard button/axis ids when possible.
webxr_interface.xr_standard_mapping = true
# WebXR uses a lot of asynchronous callbacks, so we connect to various
# signals in order to receive them.
webxr_interface.connect("session_supported", self, "_webxr_session_supported")
webxr_interface.connect("session_started", self, "_webxr_session_started")
webxr_interface.connect("session_ended", self, "_webxr_session_ended")
webxr_interface.connect("session_failed", self, "_webxr_session_failed")
# This returns immediately - our _webxr_session_supported() method
# (which we connected to the "session_supported" signal above) will
# be called sometime later to let us know if it's supported or not.
webxr_interface.is_session_supported("immersive-vr")
func _webxr_session_supported(session_mode, supported):
if session_mode == 'immersive-vr':
vr_supported = supported
func _on_Button_pressed():
if not vr_supported:
OS.alert("Your browser doesn't support VR")
return
# We want an immersive VR session, as opposed to AR ('immersive-ar') or a
# simple 3DoF viewer ('viewer').
webxr_interface.session_mode = 'immersive-vr'
# 'bounded-floor' is room scale, 'local-floor' is a standing or sitting
# experience (it puts you 1.6m above the ground if you have 3DoF headset),
# whereas as 'local' puts you down at the ARVROrigin.
# This list means it'll first try to request 'bounded-floor', then
# fallback on 'local-floor' and ultimately 'local', if nothing else is
# supported.
webxr_interface.requested_reference_space_types = 'bounded-floor, local-floor, local'
# In order to use 'local-floor' or 'bounded-floor' we must also
# mark the features as required or optional.
webxr_interface.required_features = 'local-floor'
webxr_interface.optional_features = 'bounded-floor'
# This will return false if we're unable to even request the session,
# however, it can still fail asynchronously later in the process, so we
# only know if it's really succeeded or failed when our
# _webxr_session_started() or _webxr_session_failed() methods are called.
if not webxr_interface.initialize():
OS.alert("Failed to initialize")
return
func _webxr_session_started():
$Button.visible = false
# This tells Godot to start rendering to the headset.
get_viewport().arvr = true
# This will be the reference space type you ultimately got, out of the
# types that you requested above. This is useful if you want the game to
# work a little differently in 'bounded-floor' versus 'local-floor'.
print ("Reference space type: " + webxr_interface.reference_space_type)
func _webxr_session_ended():
$Button.visible = true
# If the user exits immersive mode, then we tell Godot to render to the web
# page again.
get_viewport().arvr = false
func _webxr_session_failed(message):
OS.alert("Failed to initialize: " + message)
There are several ways to handle "controller" input:
- Using nodes and their ARVRController.button_pressed and ARVRController.button_release signals. This is how controllers are typically handled in AR/VR apps in Godot, however, this will only work with advanced VR controllers like the Oculus Touch or Index controllers, for example. The buttons codes are defined by Section 3.3 of the WebXR Gamepads Module.
- Using and or . This works the same as normal joypads, except the starts at 100, so the left controller is 100 and the right controller is 101, and the button codes are also defined by Section 3.3 of the WebXR Gamepads Module.
- Using the select, squeeze and related signals. This method will work for both advanced VR controllers, and non-traditional "controllers" like a tap on the screen, a spoken voice command or a button press on the device itself. The controller_id passed to these signals is the same id as used in .
You can use one or all of these methods to allow your game or app to support a wider or narrower set of devices and input methods, or to allow more advanced interactions with more advanced devices.
We don't know the target ray mode.
Target ray originates at the viewer's eyes and points in the direction they are looking.
Target ray from a handheld pointer, most likely a VR touch controller.
Target ray from touch screen, mouse or other tactile input device.
The session mode used by when setting up the WebXR session.
This doesn't have any effect on the interface when already initialized.
Possible values come from WebXR's XRSessionMode, including: "immersive-vr", "immersive-ar", and "inline".
A comma-seperated list of required features used by when setting up the WebXR session.
If a user's browser or device doesn't support one of the given features, initialization will fail and session_failed will be emitted.
This doesn't have any effect on the interface when already initialized.
Possible values come from WebXR's XRReferenceSpaceType. If you want to use a particular reference space type, it must be listed in either or .
A comma-seperated list of optional features used by when setting up the WebXR session.
If a user's browser or device doesn't support one of the given features, initialization will continue, but you won't be able to use the requested feature.
This doesn't have any effect on the interface when already initialized.
Possible values come from WebXR's XRReferenceSpaceType. If you want to use a particular reference space type, it must be listed in either or .
A comma-seperated list of reference space types used by when setting up the WebXR session.
The reference space types are requested in order, and the first on supported by the users device or browser will be used. The property contains the reference space type that was ultimately used.
This doesn't have any effect on the interface when already initialized.
Possible values come from WebXR's XRReferenceSpaceType. If you want to use a particular reference space type, it must be listed in either or .
The reference space type (from the list of requested types set in the property), that was ultimately used by when setting up the WebXR session.
Possible values come from WebXR's XRReferenceSpaceType. If you want to use a particular reference space type, it must be listed in either or .
Indicates if the WebXR session's imagery is visible to the user.
Possible values come from WebXR's XRVisibilityState, including "hidden", "visible", and "visible-blurred".
The vertices of a polygon which defines the boundaries of the user's play area.
This will only be available if is "bounded-floor" and only on certain browsers and devices that support it.
The reference_space_reset signal may indicate when this changes.
If set to true, the button and axes ids will be converted to match the standard ids used by other AR/VR interfaces, when possible.
Otherwise, the ids will be passed through unaltered from WebXR.
Checks if the given session_mode is supported by the user's browser.
Possible values come from WebXR's XRSessionMode, including: "immersive-vr", "immersive-ar", and "inline".
This method returns nothing, instead it emits the session_supported signal with the result.
Gets an for the given controller_id.
In the context of WebXR, a "controller" can be an advanced VR controller like the Oculus Touch or Index controllers, or even a tap on the screen, a spoken voice command or a button press on the device itself. When a non-traditional controller is used, interpret the position and orientation of the as a ray pointing at the object the user wishes to interact with.
Use this method to get information about the controller that triggered one of these signals:
- selectstart
- select
- selectend
- squeezestart
- squeeze
- squeezestart
Returns the target ray mode for the given controller_id.
This can help interpret the input coming from that controller. See XRInputSource.targetRayMode for more information.
Windowdialog is the base class for all window-based dialogs. It's a by-default toplevel that draws a window decoration and allows motion and resizing.
The text displayed in the window's title bar.
If true, the user can resize the window.
Returns the close .
Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their property.
Class that has everything pertaining to a world. A physics space, a visual scenario, a navigation map and a sound space. Spatial nodes register their resources into the current world.
The World's .
The World's fallback environment will be used if fails or is missing.
The World's physics space.
The World's visual scenario.
The of this world's navigation map. Used by the .
Direct access to the world's physics 3D space state. Used for querying current and potential collisions.
Class that has everything pertaining to a 2D world. A physics space, a visual scenario, a navigation map and a sound space. 2D nodes register their resources into the current 2D world.
The of this world's canvas resource. Used by the for 2D drawing.
The of this world's physics space resource. Used by the for 2D physics, treating it as both a space and an area.
The of this world's navigation map. Used by the .
Direct access to the world's physics 2D space state. Used for querying current and potential collisions. When using multi-threaded physics, access is limited to _physics_process(delta) in the main thread.
The node is used to configure the default for the scene.
The parameters defined in the can be overridden by an node set on the current . Additionally, only one may be instanced in a given scene at a time.
The allows the user to specify default lighting parameters (e.g. ambient lighting), various post-processing effects (e.g. SSAO, DOF, Tonemapping), and how to draw the background (e.g. solid color, skybox). Usually, these are added in order to improve the realism/color balance of the scene.
The resource used by this , defining the default properties.
The X509Certificate class represents an X509 certificate. Certificates can be loaded and saved like any other .
They can be used as the server certificate in (along with the proper ), and to specify the only certificate that should be accepted when connecting to an SSL server via .
Saves a certificate to the given path (should be a "*.crt" file).
Loads a certificate from path ("*.crt" file).
This class can serve as base to make custom XML parsers. Since XML is a very flexible standard, this interface is low-level so it can be applied to any possible schema.
There's no node (no file or buffer opened).
Element (tag).
End of element.
Text node.
Comment node.
CDATA content.
Unknown node.
Reads the next node of the file. This returns an error code.
Gets the type of the current node. Compare with constants.
Gets the name of the current element node. This will raise an error if the current node type is neither nor .
Gets the contents of a text node. This will raise an error in any other type of node.
Gets the byte offset of the current node since the beginning of the file or buffer.
Gets the amount of attributes in the current element.
Gets the name of the attribute specified by the index in idx argument.
Gets the value of the attribute specified by the index in idx argument.
Check whether the current element has a certain attribute.
Gets the value of a certain attribute of the current element by name. This will raise an error if the element has no such attribute.
Gets the value of a certain attribute of the current element by name. This will return an empty if the attribute is not found.
Check whether the current element is empty (this only works for completely empty tags, e.g. <element \>).
Gets the current line in the parsed file (currently not implemented).
Skips the current section. If the node contains other elements, they will be ignored and the cursor will go to the closing of the current element.
Moves the buffer cursor to a certain offset (since the beginning) and read the next node there. This returns an error code.
Opens an XML file for parsing. This returns an error code.
Opens an XML raw buffer for parsing. This returns an error code.
Sort all child nodes based on their Y positions. The child node must inherit from for it to be sorted. Nodes that have a higher Y position will be drawn later, so they will appear on top of nodes that have a lower Y position.
Nesting of YSort nodes is possible. Children YSort nodes will be sorted in the same space as the parent YSort, allowing to better organize a scene or divide it in multiple ones, yet keep the unique sorting.
If true, child nodes are sorted, otherwise sorting is disabled.
Provides access to metadata stored for every available class.
Returns the names of all the classes available.
Returns the names of all the classes that directly or indirectly inherit from class.
Returns the parent class of class.
Returns whether the specified class is available or not.
Returns whether inherits is an ancestor of class or not.
Returns true if you can instance objects from the specified class, false in other case.
Creates an instance of class.
Returns whether class or its ancestry has a signal called signal or not.
Returns the signal data of class or its ancestry. The returned value is a with the following keys: args, default_args, flags, id, name, return: (class_name, hint, hint_string, name, type, usage).
Returns an array with all the signals of class or its ancestry if no_inheritance is false. Every element of the array is a as described in .
Returns an array with all the properties of class or its ancestry if no_inheritance is false.
Returns the value of property of class or its ancestry.
Sets property value of class to value.
Returns whether class (or its ancestry if no_inheritance is false) has a method called method or not.
Returns an array with all the methods of class or its ancestry if no_inheritance is false. Every element of the array is a with the following keys: args, default_args, flags, id, name, return: (class_name, hint, hint_string, name, type, usage).
Note: In exported release builds the debug info is not available, so the returned dictionaries will contain only method names.
Returns an array with the names all the integer constants of class or its ancestry.
Returns whether class or its ancestry has an integer constant called name or not.
Returns the value of the integer constant name of class or its ancestry. Always returns 0 when the constant could not be found.
Returns whether class or its ancestry has an enum called name or not.
Returns an array with all the enums of class or its ancestry.
Returns an array with all the keys in enum of class or its ancestry.
Returns which enum the integer constant name of class or its ancestry belongs to.
Returns a category associated with the class for use in documentation and the Asset Library. Debug mode required.
Returns whether this class is enabled or not.
Directory type. It is used to manage directories and their content (not restricted to the project folder).
When creating a new , its default opened directory will be res://. This may change in the future, so it is advised to always use to initialize your where you want to operate, with explicit error checking.
Note: Many resources types are imported (e.g. textures or sound files), and their source asset will not be included in the exported game, as only the imported version is used. Use to access imported resources.
Here is an example on how to iterate through the files of a directory:
func dir_contents(path):
var dir = Directory.new()
if dir.open(path) == OK:
dir.list_dir_begin()
var file_name = dir.get_next()
while file_name != "":
if dir.current_is_dir():
print("Found directory: " + file_name)
else:
print("Found file: " + file_name)
file_name = dir.get_next()
else:
print("An error occurred when trying to access the path.")
Opens an existing directory of the filesystem. The path argument can be within the project tree (res://folder), the user directory (user://folder) or an absolute path of the user filesystem (e.g. /tmp/folder or C:\tmp\folder).
Returns one of the code constants (OK on success).
Initializes the stream used to list all files and directories using the function, closing the currently opened stream if needed. Once the stream has been processed, it should typically be closed with .
If skip_navigational is true, . and .. are filtered out.
If skip_hidden is true, hidden files are filtered out.
Returns the next element (file or directory) in the current directory (including . and .., unless skip_navigational was given to ).
The name of the file or directory is returned (and not its full path). Once the stream has been fully processed, the method returns an empty String and closes the stream automatically (i.e. would not be mandatory in such a case).
Returns whether the current item processed with the last call is a directory (. and .. are considered directories).
Closes the current stream opened with (whether it has been fully processed with does not matter).
On Windows, returns the number of drives (partitions) mounted on the current filesystem.
On macOS, returns the number of mounted volumes.
On Linux, returns the number of mounted volumes and GTK 3 bookmarks.
On other platforms, the method returns 0.
On Windows, returns the name of the drive (partition) passed as an argument (e.g. C:).
On macOS, returns the path to the mounted volume passed as an argument.
On Linux, returns the path to the mounted volume or GTK 3 bookmark passed as an argument.
On other platforms, or if the requested drive does not exist, the method returns an empty String.
Returns the currently opened directory's drive index. See to convert returned index to the name of the drive.
Changes the currently opened directory to the one passed as an argument. The argument can be relative to the current directory (e.g. newdir or ../newdir), or an absolute path (e.g. /tmp/newdir or res://somedir/newdir).
Returns one of the code constants (OK on success).
Returns the absolute path to the currently opened directory (e.g. res://folder or C:\tmp\folder).
Creates a directory. The argument can be relative to the current directory, or an absolute path. The target directory should be placed in an already existing directory (to create the full path recursively, see ).
Returns one of the code constants (OK on success).
Creates a target directory and all necessary intermediate directories in its path, by calling recursively. The argument can be relative to the current directory, or an absolute path.
Returns one of the code constants (OK on success).
Returns whether the target file exists. The argument can be relative to the current directory, or an absolute path.
Returns whether the target directory exists. The argument can be relative to the current directory, or an absolute path.
On UNIX desktop systems, returns the available space on the current directory's disk. On other platforms, this information is not available and the method returns 0 or -1.
Copies the from file to the to destination. Both arguments should be paths to files, either relative or absolute. If the destination file exists and is not access-protected, it will be overwritten.
Returns one of the code constants (OK on success).
Renames (move) the from file or directory to the to destination. Both arguments should be paths to files or directories, either relative or absolute. If the destination file or directory exists and is not access-protected, it will be overwritten.
Returns one of the code constants (OK on success).
Permanently deletes the target file or an empty directory. The argument can be relative to the current directory, or an absolute path. If the target directory is not empty, the operation will fail.
If you don't want to delete the file/directory permanently, use instead.
Returns one of the code constants (OK on success).
The singleton allows you to query and modify the project's run-time parameters, such as frames per second, time scale, and others.
If true, the script is currently running inside the editor. This is useful for tool scripts to conditionally draw editor helpers, or prevent accidentally running "game" code that would affect the scene state while in the editor:
if Engine.editor_hint:
draw_gizmos()
else:
simulate_physics()
See Running code in the editor in the documentation for more information.
Note: To detect whether the script is run from an editor build (e.g. when pressing F5), use with the "editor" argument instead. OS.has_feature("editor") will evaluate to true both when the code is running in the editor and when running the project from the editor, but it will evaluate to false when the code is run from an exported project.
If false, stops printing error and warning messages to the console and editor Output log. This can be used to hide error and warning messages during unit test suite runs. This property is equivalent to the project setting.
Warning: If you set this to false anywhere in the project, important error messages may be hidden even if they are emitted from other scripts. If this is set to false in a tool script, this will also impact the editor itself. Do not report bugs before ensuring error messages are enabled (as they are by default).
Note: This property does not impact the editor's Errors tab when running a project from the editor.
The number of fixed iterations per second. This controls how often physics simulation and methods are run. This value should generally always be set to 60 or above, as Godot doesn't interpolate the physics step. As a result, values lower than 60 will look stuttery. This value can be increased to make input more reactive or work around collision tunneling issues, but keep in mind doing so will increase CPU usage. See also and .
Note: Only 8 physics ticks may be simulated per rendered frame at most. If more than 8 physics ticks have to be simulated per rendered frame to keep up with rendering, the game will appear to slow down (even if delta is used consistently in physics calculations). Therefore, it is recommended not to increase above 240. Otherwise, the game will slow down when the rendering framerate goes below 30 FPS.
The desired frames per second. If the hardware cannot keep up, this setting may not be respected. A value of 0 means no limit.
Controls how fast or slow the in-game clock ticks versus the real life one. It defaults to 1.0. A value of 2.0 means the game moves twice as fast as real life, whilst a value of 0.5 means the game moves at half the regular speed.
Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of the in-game clock and real clock but smooth out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended.
Note: For best results, when using a custom physics interpolation solution, the physics jitter fix should be disabled by setting to 0.
Returns the fraction through the current physics tick we are at the time of rendering the frame. This can be used to implement fixed timestep interpolation.
Returns the total number of frames drawn. On headless platforms, or if the render loop is disabled with --disable-render-loop via command line, always returns 0. See .
Returns the frames per second of the running game.
Returns the total number of frames passed since engine initialization which is advanced on each physics frame. See also .
can be used to run expensive logic less often without relying on a :
func _physics_process(_delta):
if Engine.get_physics_frames() % 2 == 0:
pass # Run expensive logic only once every 2 physics frames here.
Returns the total number of frames passed since engine initialization which is advanced on each idle frame, regardless of whether the render loop is enabled. See also and .
can be used to run expensive logic less often without relying on a :
func _process(_delta):
if Engine.get_idle_frames() % 2 == 0:
pass # Run expensive logic only once every 2 idle (render) frames here.
Returns the main loop object (see and ).
Returns the current engine version information in a Dictionary.
major - Holds the major version number as an int
minor - Holds the minor version number as an int
patch - Holds the patch version number as an int
hex - Holds the full version number encoded as a hexadecimal int with one byte (2 places) per number (see example below)
status - Holds the status (e.g. "beta", "rc1", "rc2", ... "stable") as a String
build - Holds the build name (e.g. "custom_build") as a String
hash - Holds the full Git commit hash as a String
year - Holds the year the version was released in as an int
string - major + minor + patch + status + build in a single String
The hex value is encoded as follows, from left to right: one byte for the major, one byte for the minor, one byte for the patch version. For example, "3.1.12" would be 0x03010C. Note: It's still an int internally, and printing it will give you its decimal representation, which is not particularly meaningful. Use hexadecimal literals for easy version comparisons from code:
if Engine.get_version_info().hex >= 0x030200:
# Do things specific to version 3.2 or later
else:
# Do things specific to versions before 3.2
Returns engine author information in a Dictionary.
lead_developers - Array of Strings, lead developer names
founders - Array of Strings, founder names
project_managers - Array of Strings, project manager names
developers - Array of Strings, developer names
Returns an Array of copyright information Dictionaries.
name - String, component name
parts - Array of Dictionaries {files, copyright, license} describing subsections of the component
Returns a Dictionary of Arrays of donor names.
{platinum_sponsors, gold_sponsors, silver_sponsors, bronze_sponsors, mini_sponsors, gold_donors, silver_donors, bronze_donors}
Returns Dictionary of licenses used by Godot and included third party components.
Returns Godot license text.
Returns true if the game is inside the fixed process and physics phase of the game loop.
Returns true if a singleton with given name exists in global scope.
Returns a global singleton with given name. Often used for plugins, e.g. GodotPayment on Android.
File type. This is used to permanently store data into the user device's file system and to read from it. This can be used to store game save data or player configuration files, for example.
Here's a sample on how to write and read from a file:
func save(content):
var file = File.new()
file.open("user://save_game.dat", File.WRITE)
file.store_string(content)
file.close()
func load():
var file = File.new()
file.open("user://save_game.dat", File.READ)
var content = file.get_as_text()
file.close()
return content
In the example above, the file will be saved in the user data folder as specified in the Data paths documentation.
Note: To access project resources once exported, it is recommended to use instead of the API, as some files are converted to engine-specific formats and their original source files might not be present in the exported PCK package.
Note: Files are automatically closed only if the process exits "normally" (such as by clicking the window manager's close button or pressing Alt + F4). If you stop the project execution by pressing F8 while the project is running, the file won't be closed as the game process will be killed. You can work around this by calling at regular intervals.
Uses the FastLZ compression method.
Uses the DEFLATE compression method.
Uses the Zstandard compression method.
Uses the gzip compression method.
Opens the file for read operations. The cursor is positioned at the beginning of the file.
Opens the file for write operations. The file is created if it does not exist, and truncated if it does.
Opens the file for read and write operations. Does not truncate the file. The cursor is positioned at the beginning of the file.
Opens the file for read and write operations. The file is created if it does not exist, and truncated if it does. The cursor is positioned at the beginning of the file.
If true, the file is read with big-endian endianness. If false, the file is read with little-endian endianness. If in doubt, leave this to false as most files are written with little-endian endianness.
Note: is only about the file format, not the CPU type. The CPU endianness doesn't affect the default endianness for files written.
Note: This is always reset to false whenever you open the file. Therefore, you must set after opening the file, not before.
Opens an encrypted file in write or read mode. You need to pass a binary key to encrypt/decrypt it.
Note: The provided key must be 32 bytes long.
Opens an encrypted file in write or read mode. You need to pass a password to encrypt/decrypt it.
Opens a compressed file for reading or writing.
Note: can only read files that were saved by Godot, not third-party compression formats. See GitHub issue #28999 for a workaround.
Opens the file for writing or reading, depending on the flags.
Writes the file's buffer to disk. Flushing is automatically performed when the file is closed. This means you don't need to call manually before closing a file using . Still, calling can be used to ensure the data is safe even if the project crashes instead of being closed gracefully.
Note: Only call when you actually need it. Otherwise, it will decrease performance due to constant disk writes.
Closes the currently opened file and prevents subsequent read/write operations. Use to persist the data to disk without closing the file.
Returns the path as a for the current open file.
Returns the absolute path as a for the current open file.
Returns true if the file is currently opened.
Changes the file reading/writing cursor to the specified position (in bytes from the beginning of the file).
Changes the file reading/writing cursor to the specified position (in bytes from the end of the file).
Note: This is an offset, so you should use negative numbers or the cursor will be at the end of the file.
Returns the file cursor's position.
Returns the size of the file in bytes.
Returns true if the file cursor has already read past the end of the file.
Note: eof_reached() == false cannot be used to check whether there is more data available. To loop while there is more data available, use:
while file.get_position() < file.get_len():
# Read data
Returns the next 8 bits from the file as an integer. See for details on what values can be stored and retrieved this way.
Returns the next 16 bits from the file as an integer. See for details on what values can be stored and retrieved this way.
Returns the next 32 bits from the file as an integer. See for details on what values can be stored and retrieved this way.
Returns the next 64 bits from the file as an integer. See for details on what values can be stored and retrieved this way.
Returns the next 32 bits from the file as a floating-point number.
Returns the next 64 bits from the file as a floating-point number.
Returns the next bits from the file as a floating-point number.
Returns next len bytes of the file as a .
Returns the next line of the file as a .
Text is interpreted as being UTF-8 encoded.
Returns the next value of the file in CSV (Comma-Separated Values) format. You can pass a different delimiter delim to use other than the default "," (comma). This delimiter must be one-character long, and cannot be a double quotation mark.
Text is interpreted as being UTF-8 encoded. Text values must be enclosed in double quotes if they include the delimiter character. Double quotes within a text value can be escaped by doubling their occurrence.
For example, the following CSV lines are valid and will be properly parsed as two strings each:
Alice,"Hello, Bob!"
Bob,Alice! What a surprise!
Alice,"I thought you'd reply with ""Hello, world""."
Note how the second line can omit the enclosing quotes as it does not include the delimiter. However it could very well use quotes, it was only written without for demonstration purposes. The third line must use "" for each quotation mark that needs to be interpreted as such instead of the end of a text value.
Returns the whole file as a . Text is interpreted as being UTF-8 encoded.
If skip_cr is true, carriage return characters (\r, CR) will be ignored when parsing the UTF-8, so that only line feed characters (\n, LF) represent a new line (Unix convention).
Returns an MD5 String representing the file at the given path or an empty on failure.
Returns a SHA-256 representing the file at the given path or an empty on failure.
Returns the last error that happened when trying to perform operations. Compare with the ERR_FILE_* constants from .
Returns the next Variant value from the file. If allow_objects is true, decoding objects is allowed.
Warning: Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
Stores an integer as 8 bits in the file.
Note: The value should lie in the interval [0, 255]. Any other value will overflow and wrap around.
To store a signed integer, use , or convert it manually (see for an example).
Stores an integer as 16 bits in the file.
Note: The value should lie in the interval [0, 2^16 - 1]. Any other value will overflow and wrap around.
To store a signed integer, use or store a signed integer from the interval [-2^15, 2^15 - 1] (i.e. keeping one bit for the signedness) and compute its sign manually when reading. For example:
const MAX_15B = 1 << 15
const MAX_16B = 1 << 16
func unsigned16_to_signed(unsigned):
return (unsigned + MAX_15B) % MAX_16B - MAX_15B
func _ready():
var f = File.new()
f.open("user://file.dat", File.WRITE_READ)
f.store_16(-42) # This wraps around and stores 65494 (2^16 - 42).
f.store_16(121) # In bounds, will store 121.
f.seek(0) # Go back to start to read the stored value.
var read1 = f.get_16() # 65494
var read2 = f.get_16() # 121
var converted1 = unsigned16_to_signed(read1) # -42
var converted2 = unsigned16_to_signed(read2) # 121
Stores an integer as 32 bits in the file.
Note: The value should lie in the interval [0, 2^32 - 1]. Any other value will overflow and wrap around.
To store a signed integer, use , or convert it manually (see for an example).
Stores an integer as 64 bits in the file.
Note: The value must lie in the interval [-2^63, 2^63 - 1] (i.e. be a valid value).
Stores a floating-point number as 32 bits in the file.
Stores a floating-point number as 64 bits in the file.
Stores a floating-point number in the file.
Stores the given array of bytes in the file.
Appends line to the file followed by a line return character (\n), encoding the text as UTF-8.
Store the given in the file as a line formatted in the CSV (Comma-Separated Values) format. You can pass a different delimiter delim to use other than the default "," (comma). This delimiter must be one-character long.
Text will be encoded as UTF-8.
Appends string to the file without a line return, encoding the text as UTF-8.
Note: This method is intended to be used to write text files. The string is stored as a UTF-8 encoded buffer without string length or terminating zero, which means that it can't be loaded back easily. If you want to store a retrievable string in a binary file, consider using instead. For retrieving strings from a text file, you can use get_buffer(length).get_string_from_utf8() (if you know the length) or .
Stores any Variant value in the file. If full_objects is true, encoding objects is allowed (and can potentially include code).
Note: Not all properties are included. Only properties that are configured with the PROPERTY_USAGE_STORAGE flag set will be serialized. You can add a new usage flag to a property by overriding the method in your class. You can also check how property usage is configured by calling . See for the possible usage flags.
Stores the given as a line in the file in Pascal format (i.e. also store the length of the string).
Text will be encoded as UTF-8.
Returns a saved in Pascal format from the file.
Text is interpreted as being UTF-8 encoded.
Returns true if the file exists in the given path.
Note: Many resources types are imported (e.g. textures or sound files), and their source asset will not be included in the exported game, as only the imported version is used. See for an alternative approach that takes resource remapping into account.
Returns the last time the file was modified in unix timestamp format or returns a "ERROR IN file". This unix timestamp can be converted to datetime by using .
Geometry provides users with a set of helper functions to create geometric shapes, compute intersections between shapes, and process various other geometric operations.
Endpoints are joined using the value and the path filled as a polygon.
Endpoints are joined using the value and the path filled as a polyline.
Endpoints are squared off with no extension.
Endpoints are squared off and extended by delta units.
Endpoints are rounded off and extended by delta units.
Create regions where either subject or clip polygons (or both) are filled.
Create regions where subject polygons are filled except where clip polygons are filled.
Create regions where both subject and clip polygons are filled.
Create regions where either subject or clip polygons are filled but not where both are filled.
Squaring is applied uniformally at all convex edge joins at 1 * delta.
While flattened paths can never perfectly trace an arc, they are approximated by a series of arc chords.
There's a necessary limit to mitered joins since offsetting edges that join at very acute angles will produce excessively long and narrow "spikes". For any given edge join, when miter offsetting would exceed that maximum distance, "square" joining is applied.
Returns an array with 6 s that describe the sides of a box centered at the origin. The box size is defined by extents, which represents one (positive) corner of the box (i.e. half its actual size).
Returns an array of s closely bounding a faceted cylinder centered at the origin with radius radius and height height. The parameter sides defines how many planes will be generated for the round part of the cylinder. The parameter axis describes the axis along which the cylinder is oriented (0 for X, 1 for Y, 2 for Z).
Returns an array of s closely bounding a faceted capsule centered at the origin with radius radius and height height. The parameter sides defines how many planes will be generated for the side part of the capsule, whereas lats gives the number of latitudinal steps at the bottom and top of the capsule. The parameter axis describes the axis along which the capsule is oriented (0 for X, 1 for Y, 2 for Z).
Returns true if point is inside the circle or if it's located exactly on the circle's boundary, otherwise returns false.
Given the 2D segment (segment_from, segment_to), returns the position on the segment (as a number between 0 and 1) at which the segment hits the circle that is located at position circle_position and has radius circle_radius. If the segment does not intersect the circle, -1 is returned (this is also the case if the line extending the segment would intersect the circle, but the segment does not).
Checks if the two segments (from_a, to_a) and (from_b, to_b) intersect. If yes, return the point of intersection as . If no intersection takes place, returns null.
Checks if the two lines (from_a, dir_a) and (from_b, dir_b) intersect. If yes, return the point of intersection as . If no intersection takes place, returns null.
Note: The lines are specified using direction vectors, not end points.
Given the two 2D segments (p1, q1) and (p2, q2), finds those two points on the two segments that are closest to each other. Returns a that contains this point on (p1, q1) as well the accompanying point on (p2, q2).
Given the two 3D segments (p1, p2) and (q1, q2), finds those two points on the two segments that are closest to each other. Returns a that contains this point on (p1, p2) as well the accompanying point on (q1, q2).
Returns the 2D point on the 2D segment (s1, s2) that is closest to point. The returned point will always be inside the specified segment.
Returns the 3D point on the 3D segment (s1, s2) that is closest to point. The returned point will always be inside the specified segment.
Returns the 2D point on the 2D line defined by (s1, s2) that is closest to point. The returned point can be inside the segment (s1, s2) or outside of it, i.e. somewhere on the line extending from the segment.
Returns the 3D point on the 3D line defined by (s1, s2) that is closest to point. The returned point can be inside the segment (s1, s2) or outside of it, i.e. somewhere on the line extending from the segment.
Used internally by the engine.
Tests if the 3D ray starting at from with the direction of dir intersects the triangle specified by a, b and c. If yes, returns the point of intersection as . If no intersection takes place, an empty Variant is returned.
Tests if the segment (from, to) intersects the triangle a, b, c. If yes, returns the point of intersection as . If no intersection takes place, an empty Variant is returned.
Checks if the segment (from, to) intersects the sphere that is located at sphere_position and has radius sphere_radius. If no, returns an empty . If yes, returns a containing the point of intersection and the sphere's normal at the point of intersection.
Checks if the segment (from, to) intersects the cylinder with height height that is centered at the origin and has radius radius. If no, returns an empty . If an intersection takes place, the returned array contains the point of intersection and the cylinder's normal at the point of intersection.
Given a convex hull defined though the s in the array planes, tests if the segment (from, to) intersects with that hull. If an intersection is found, returns a containing the point the intersection and the hull's normal. If no intersecion is found, an the returned array is empty.
Returns if point is inside the triangle specified by a, b and c.
Returns true if polygon's vertices are ordered in clockwise order, otherwise returns false.
Returns true if point is inside polygon or if it's located exactly on polygon's boundary, otherwise returns false.
Triangulates the polygon specified by the points in polygon. Returns a where each triangle consists of three consecutive point indices into polygon (i.e. the returned array will have n * 3 elements, with n being the number of found triangles). Output triangles will always be counter clockwise, and the contour will be flipped if it's clockwise. If the triangulation did not succeed, an empty is returned.
Triangulates the area specified by discrete set of points such that no point is inside the circumcircle of any resulting triangle. Returns a where each triangle consists of three consecutive point indices into points (i.e. the returned array will have n * 3 elements, with n being the number of found triangles). If the triangulation did not succeed, an empty is returned.
Given an array of s, returns the convex hull as a list of points in counterclockwise order. The last point is the same as the first one.
Clips the polygon defined by the points in points against the plane and returns the points of the clipped polygon.
Merges (combines) polygon_a and polygon_b and returns an array of merged polygons. This performs between polygons.
The operation may result in an outer polygon (boundary) and multiple inner polygons (holes) produced which could be distinguished by calling .
Clips polygon_a against polygon_b and returns an array of clipped polygons. This performs between polygons. Returns an empty array if polygon_b completely overlaps polygon_a.
If polygon_b is enclosed by polygon_a, returns an outer polygon (boundary) and inner polygon (hole) which could be distinguished by calling .
Intersects polygon_a with polygon_b and returns an array of intersected polygons. This performs between polygons. In other words, returns common area shared by polygons. Returns an empty array if no intersection occurs.
The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling .
Mutually excludes common area defined by intersection of polygon_a and polygon_b (see ) and returns an array of excluded polygons. This performs between polygons. In other words, returns all but common area between polygons.
The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling .
Clips polyline against polygon and returns an array of clipped polylines. This performs between the polyline and the polygon. This operation can be thought of as cutting a line with a closed shape.
Intersects polyline with polygon and returns an array of intersected polylines. This performs between the polyline and the polygon. This operation can be thought of as chopping a line with a closed shape.
Inflates or deflates polygon by delta units (pixels). If delta is positive, makes the polygon grow outward. If delta is negative, shrinks the polygon inward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. Returns an empty array if delta is negative and the absolute value of it approximately exceeds the minimum bounding rectangle dimensions of the polygon.
Each polygon's vertices will be rounded as determined by join_type, see .
The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling .
Note: To translate the polygon's vertices specifically, use the Transform2D.xform method:
var polygon = PoolVector2Array([Vector2(0, 0), Vector2(100, 0), Vector2(100, 100), Vector2(0, 100)])
var offset = Vector2(50, 50)
polygon = Transform2D(0, offset).xform(polygon)
print(polygon) # prints [Vector2(50, 50), Vector2(150, 50), Vector2(150, 150), Vector2(50, 150)]
Inflates or deflates polyline by delta units (pixels), producing polygons. If delta is positive, makes the polyline grow outward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. If delta is negative, returns an empty array.
Each polygon's vertices will be rounded as determined by join_type, see .
Each polygon's endpoints will be rounded as determined by end_type, see .
The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling .
Given an array of s representing tiles, builds an atlas. The returned dictionary has two keys: points is an array of that specifies the positions of each tile, size contains the overall size of the whole atlas as .
This class is a bridge between Godot and the Mono runtime. It exposes several low-level operations and is only available in Mono-enabled Godot builds.
See also .
Attaches the current thread to the Mono runtime.
Detaches the current thread from the Mono runtime.
Returns the current MonoDomain ID.
Note: The Mono runtime must be initialized for this method to work (use to check). If the Mono runtime isn't initialized at the time this method is called, the engine will crash.
Returns the scripts MonoDomain's ID. This will be the same MonoDomain ID as , unless the scripts domain isn't loaded.
Note: The Mono runtime must be initialized for this method to work (use to check). If the Mono runtime isn't initialized at the time this method is called, the engine will crash.
Returns true if the scripts domain is loaded, false otherwise.
Returns true if the domain is being finalized, false otherwise.
Returns true if the Mono runtime is shutting down, false otherwise.
Returns true if the Mono runtime is initialized, false otherwise.
Helper class for parsing JSON data. For usage example and other important hints, see .
Converts a Variant var to JSON text and returns the result. Useful for serializing data to store or send over the network.
Note: The JSON specification does not define integer or float types, but only a number type. Therefore, converting a Variant to JSON text will convert all numerical values to types.
The indent parameter controls if and how something is indented, the string used for this parameter will be used where there should be an indent in the output, even spaces like " " will work. \t and \n can also be used for a tab indent, or to make a newline for each indent respectively.
Example output:
## JSON.print(my_dictionary)
{"name":"my_dictionary","version":"1.0.0","entities":[{"name":"entity_0","value":"value_0"},{"name":"entity_1","value":"value_1"}]}
## JSON.print(my_dictionary, "\t")
{
"name": "my_dictionary",
"version": "1.0.0",
"entities": [
{
"name": "entity_0",
"value": "value_0"
},
{
"name": "entity_1",
"value": "value_1"
}
]
}
## JSON.print(my_dictionary, "...")
{
..."name": "my_dictionary",
..."version": "1.0.0",
..."entities": [
......{
........."name": "entity_0",
........."value": "value_0"
......},
......{
........."name": "entity_1",
........."value": "value_1"
......}
...]
}
Parses a JSON-encoded string and returns a containing the result.
Provides data transformation and encoding utility functions.
Returns a Base64-encoded string of the Variant variant. If full_objects is true, encoding objects is allowed (and can potentially include code).
Returns a decoded Variant corresponding to the Base64-encoded string base64_str. If allow_objects is true, decoding objects is allowed.
Warning: Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
Returns a Base64-encoded string of a given .
Returns a decoded corresponding to the Base64-encoded string base64_str.
Returns a Base64-encoded string of the UTF-8 string utf8_str.
Returns a decoded string corresponding to the Base64-encoded string base64_str.
A synchronization mutex (mutual exclusion). This is used to synchronize multiple s, and is equivalent to a binary . It guarantees that only one thread can ever acquire the lock at a time. A mutex can be used to protect a critical section; however, be careful to avoid deadlocks.
Locks this , blocks until it is unlocked by the current owner.
Note: This function returns without blocking if the thread already has ownership of the mutex.
Tries locking this , but does not block. Returns OK on success, ERR_BUSY otherwise.
Note: This function returns OK if the thread already has ownership of the mutex.
Unlocks this , leaving it to other threads.
Note: If a thread called or multiple times while already having ownership of the mutex, it must also call the same number of times in order to unlock it correctly.
Operating System functions. OS wraps the most common functionality to communicate with the host operating system, such as the clipboard, video driver, date and time, timers, environment variables, execution of binaries, command line, etc.
The GLES2 rendering backend. It uses OpenGL ES 2.0 on mobile devices, OpenGL 2.1 on desktop platforms and WebGL 1.0 on the web.
The GLES3 rendering backend. It uses OpenGL ES 3.0 on mobile devices, OpenGL 3.3 on desktop platforms and WebGL 2.0 on the web.
Desktop directory path.
DCIM (Digital Camera Images) directory path.
Documents directory path.
Downloads directory path.
Movies directory path.
Music directory path.
Pictures directory path.
Ringtones directory path.
Landscape screen orientation.
Portrait screen orientation.
Reverse landscape screen orientation.
Reverse portrait screen orientation.
Uses landscape or reverse landscape based on the hardware sensor.
Uses portrait or reverse portrait based on the hardware sensor.
Uses most suitable orientation based on the hardware sensor.
Unknown powerstate.
Unplugged, running on battery.
Plugged in, no battery available.
Plugged in, battery charging.
Plugged in, battery fully charged.
Application handle:
- Windows: HINSTANCE of the application
- MacOS: NSApplication* of the application (not yet implemented)
- Android: JNIEnv* of the application (not yet implemented)
Display handle:
- Linux: X11::Display* for the display
Window handle:
- Windows: HWND of the main window
- Linux: X11::Window* of the main window
- MacOS: NSWindow* of the main window (not yet implemented)
- Android: jObject the main android activity (not yet implemented)
Window view:
- Windows: HDC of the main window drawing context
- MacOS: NSView* of the main windows view (not yet implemented)
OpenGL Context:
- Windows: HGLRC
- Linux: X11::GLXContext
- MacOS: NSOpenGLContext* (not yet implemented)
January.
February.
March.
April.
May.
June.
July.
August.
September.
October.
November.
December.
Sunday.
Monday.
Tuesday.
Wednesday.
Thursday.
Friday.
Saturday.
The current tablet driver in use.
The clipboard from the host OS. Might be unavailable on some platforms.
The current screen index (starting from 0).
The exit code passed to the OS when the main loop exits. By convention, an exit code of 0 indicates success whereas a non-zero exit code indicates an error. For portability reasons, the exit code should be set between 0 and 125 (inclusive).
Note: This value will be ignored if using with an exit_code argument passed.
If true, vertical synchronization (Vsync) is enabled.
If true and vsync_enabled is true, the operating system's window compositor will be used for vsync when the compositor is enabled and the game is in windowed mode.
Note: This option is experimental and meant to alleviate stutter experienced by some users. However, some users have experienced a Vsync framerate halving (e.g. from 60 FPS to 30 FPS) when using it.
Note: This property is only implemented on Windows.
If true, the engine filters the time delta measured between each frame, and attempts to compensate for random variation. This will only operate on systems where V-Sync is active.
If true, the engine optimizes for low processor usage by only refreshing the screen if needed. Can improve battery consumption on mobile.
The amount of sleeping between frames when the low-processor usage mode is enabled (in microseconds). Higher values will result in lower CPU usage.
If true, the engine tries to keep the screen on while the game is running. Useful on mobile.
The minimum size of the window in pixels (without counting window manager decorations). Does not affect fullscreen mode. Set to (0, 0) to reset to the system's default value.
Note: By default, the project window has a minimum size of Vector2(64, 64). This prevents issues that can arise when the window is resized to a near-zero size.
The maximum size of the window (without counting window manager decorations). Does not affect fullscreen mode. Set to (0, 0) to reset to the system default value.
The current screen orientation.
If true, removes the window frame.
Note: Setting window_borderless to false disables per-pixel transparency.
If true, the window background is transparent and the window frame is removed.
Use get_tree().get_root().set_transparent_background(true) to disable main viewport background rendering.
Note: This property has no effect if setting is disabled.
Note: This property is implemented on HTML5, Linux, macOS, Windows, and Android. It can't be changed at runtime for Android. Use to set it at startup instead.
If true, the window is fullscreen.
If true, the window is maximized.
If true, the window is minimized.
If true, the window is resizable by the user.
The window position relative to the screen, the origin is the top left corner, +Y axis goes to the bottom and +X axis goes to the right.
The size of the window (without counting window manager decorations).
Returns true if there is content on the clipboard.
Add a new item with text "label" to global menu. Use "_dock" menu to add item to the macOS dock icon menu.
Note: This method is implemented on macOS.
Add a separator between items. Separators also occupy an index.
Note: This method is implemented on macOS.
Removes the item at index "idx" from the global menu. Note that the indexes of items after the removed item are going to be shifted by one.
Note: This method is implemented on macOS.
Clear the global menu, in effect removing all items.
Note: This method is implemented on macOS.
Returns the number of video drivers supported on the current platform.
Returns the name of the video driver matching the given driver index. This index is a value from , and you can use to get the current backend's index.
Returns the currently used video driver, using one of the values from .
Returns the total number of available audio drivers.
Returns the audio driver name for the given index.
Returns an array of MIDI device names.
The returned array will be empty if the system MIDI driver has not previously been initialised with .
Note: This method is implemented on Linux, macOS and Windows.
Initialises the singleton for the system MIDI driver.
Note: This method is implemented on Linux, macOS and Windows.
Shuts down system MIDI driver.
Note: This method is implemented on Linux, macOS and Windows.
Returns the number of displays attached to the host machine.
Returns the position of the specified screen by index. If screen is -1 (the default value), the current screen will be used.
Returns the dimensions in pixels of the specified screen. If screen is -1 (the default value), the current screen will be used.
Returns the dots per inch density of the specified screen. If screen is -1 (the default value), the current screen will be used.
Note: On macOS, returned value is inaccurate if fractional display scaling mode is used.
Note: On Android devices, the actual screen densities are grouped into six generalized densities:
ldpi - 120 dpi
mdpi - 160 dpi
hdpi - 240 dpi
xhdpi - 320 dpi
xxhdpi - 480 dpi
xxxhdpi - 640 dpi
Note: This method is implemented on Android, Linux, macOS and Windows. Returns 72 on unsupported platforms.
Return the scale factor of the specified screen by index. If screen is -1 (the default value), the current screen will be used.
Note: On macOS returned value is 2.0 for hiDPI (Retina) screen, and 1.0 for all other cases.
Note: This method is implemented on macOS.
Return the greatest scale factor of all screens.
Note: On macOS returned value is 2.0 if there is at least one hiDPI (Retina) screen in the system, and 1.0 in all other cases.
Note: This method is implemented on macOS.
Returns the current refresh rate of the specified screen. If screen is -1 (the default value), the current screen will be used.
Note: Returns -1.0 if Godot fails to find the refresh rate for the specified screen. On HTML5, will always return -1.0 as there is no way to retrieve the refresh rate on that platform.
To fallback to a default refresh rate if the method fails, try:
var refresh_rate = OS.get_screen_refresh_rate()
if refresh_rate < 0:
refresh_rate = 60.0
Returns unobscured area of the window where interactive controls should be rendered.
Returns an of , each of which is the bounding rectangle for a display cutout or notch. These are non-functional areas on edge-to-edge screens used by cameras and sensors. Returns an empty array if the device does not have cutouts. See also .
Note: Currently only implemented on Android. Other platforms will return an empty array even if they do have display cutouts or notches.
Sets whether the window should always be on top.
Note: This method is implemented on Linux, macOS and Windows.
Returns true if the window should always be on top of other windows.
Returns true if the window is currently focused.
Note: Only implemented on desktop platforms. On other platforms, it will always return true.
Request the user attention to the window. It'll flash the taskbar button on Windows or bounce the dock icon on OSX.
Note: This method is implemented on Linux, macOS and Windows.
Returns the window size including decorations like window borders.
Centers the window on the screen if in windowed mode.
Moves the window to the front.
Note: This method is implemented on Linux, macOS and Windows.
Returns internal structure pointers for use in GDNative plugins.
Note: This method is implemented on Linux and Windows (other OSs will soon be supported).
Sets whether IME input mode should be enabled.
If active IME handles key events before the application and creates an composition string and suggestion list.
Application can retrieve the composition status by using and functions.
Completed composition string is committed when input is finished.
Note: This method is implemented on Linux, macOS and Windows.
Sets position of IME suggestion list popup (in window coordinates).
Note: This method is implemented on Linux, macOS and Windows.
Returns the IME cursor position (the currently-edited portion of the string) relative to the characters in the composition string.
is sent to the application to notify it of changes to the IME cursor position.
Note: This method is implemented on macOS.
Returns the IME intermediate composition string.
is sent to the application to notify it of changes to the IME composition string.
Note: This method is implemented on macOS.
Returns true if the device has a touchscreen or emulates one.
Sets the window title to the specified string.
Note: This should be used sporadically. Don't set this every frame, as that will negatively affect performance on some window managers.
Note: This method is implemented on HTML5, Linux, macOS and Windows.
Sets a polygonal region of the window which accepts mouse events. Mouse events outside the region will be passed through.
Passing an empty array will disable passthrough support (all mouse events will be intercepted by the window, which is the default behavior).
# Set region, using Path2D node.
OS.set_window_mouse_passthrough($Path2D.curve.get_baked_points())
# Set region, using Polygon2D node.
OS.set_window_mouse_passthrough($Polygon2D.polygon)
# Reset region to default.
OS.set_window_mouse_passthrough([])
Note: On Windows, the portion of a window that lies outside the region is not drawn, while on Linux and macOS it is.
Note: This method is implemented on Linux, macOS and Windows.
Returns the number of logical CPU cores available on the host machine. On CPUs with HyperThreading enabled, this number will be greater than the number of physical CPU cores.
Returns the name of the CPU model on the host machine (e.g. "Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz").
Note: This method is only implemented on Windows, macOS, Linux and iOS. On Android, HTML5 and UWP, returns an empty string.
Returns the path to the current engine executable.
Execute the file at the given path with the arguments passed as an array of strings. Platform path resolution will take place. The resolved file must exist and be executable.
The arguments are used in the given order and separated by a space, so OS.execute("ping", ["-w", "3", "godotengine.org"], false) will resolve to ping -w 3 godotengine.org in the system's shell.
This method has slightly different behavior based on whether the blocking mode is enabled.
If blocking is true, the Godot thread will pause its execution while waiting for the process to terminate. The shell output of the process will be written to the output array as a single string. When the process terminates, the Godot thread will resume execution.
If blocking is false, the Godot thread will continue while the new process runs. It is not possible to retrieve the shell output in non-blocking mode, so output will be empty.
On Windows, if open_console is true and process is console app, new terminal window will be opened, it's ignored on other platforms.
The return value also depends on the blocking mode. When blocking, the method will return an exit code of the process. When non-blocking, the method returns a process ID, which you can use to monitor the process (and potentially terminate it with ). If the process forking (non-blocking) or opening (blocking) fails, the method will return -1 or another exit code.
Example of blocking mode and retrieving the shell output:
var output = []
var exit_code = OS.execute("ls", ["-l", "/tmp"], true, output)
Example of non-blocking mode, running another instance of the project and storing its process ID:
var pid = OS.execute(OS.get_executable_path(), [], false)
If you wish to access a shell built-in or perform a composite command, a platform-specific shell can be invoked. For example:
OS.execute("CMD.exe", ["/C", "cd %TEMP% && dir"], true, output)
Note: This method is implemented on Android, iOS, Linux, macOS and Windows.
Note: To execute a Windows command interpreter built-in command, specify cmd.exe in path, /c as the first argument, and the desired command as the second argument.
Note: To execute a PowerShell built-in command, specify powershell.exe in path, -Command as the first argument, and the desired command as the second argument.
Note: To execute a Unix shell built-in command, specify shell executable name in path, -c as the first argument, and the desired command as the second argument.
If the parameter is null, then the default value is new Godot.Collections.Array { }
Kill (terminate) the process identified by the given process ID (pid), e.g. the one returned by in non-blocking mode. See also .
Note: This method can also be used to kill processes that were not spawned by the game.
Note: This method is implemented on Android, iOS, Linux, macOS and Windows.
Requests the OS to open a resource with the most appropriate program. For example:
- OS.shell_open("C:\\Users\name\Downloads") on Windows opens the file explorer at the user's Downloads folder.
- OS.shell_open("https://godotengine.org") opens the default web browser on the official Godot website.
- OS.shell_open("mailto:example@example.com") opens the default email client with the "To" field set to example@example.com. See RFC 2368 - The mailto URL scheme for a list of fields that can be added.
Use to convert a res:// or user:// path into a system path for use with this method.
Note: This method is implemented on Android, iOS, HTML5, Linux, macOS and Windows.
Returns true if the child process ID (pid) is still running or false if it has terminated.
Must be a valid ID generated from .
Note: This method is implemented on Android, iOS, Linux, macOS and Windows.
Returns the project's process ID.
Note: This method is implemented on Android, iOS, Linux, macOS and Windows.
Returns the value of an environment variable. Returns an empty string if the environment variable doesn't exist.
Note: Double-check the casing of variable. Environment variable names are case-sensitive on all platforms except Windows.
Sets the value of the environment variable variable to value. The environment variable will be set for the Godot process and any process executed with after running . The environment variable will not persist to processes run after the Godot process was terminated.
Note: Double-check the casing of variable. Environment variable names are case-sensitive on all platforms except Windows.
Returns true if the environment variable with the name variable exists.
Note: Double-check the casing of variable. Environment variable names are case-sensitive on all platforms except Windows.
Returns the name of the host OS. Possible values are: "Android", "iOS", "HTML5", "OSX", "Server", "Windows", "UWP", "X11".
Returns the command-line arguments passed to the engine.
Command-line arguments can be written in any form, including both --key value and --key=value forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments.
You can also incorporate environment variables using the method.
You can set to define command-line arguments to be passed by the editor when running the project.
Here's a minimal example on how to parse command-line arguments into a dictionary using the --key=value form for arguments:
var arguments = {}
for argument in OS.get_cmdline_args():
if argument.find("=") > -1:
var key_value = argument.split("=")
arguments[key_value[0].lstrip("--")] = key_value[1]
else:
# Options without an argument will be present in the dictionary,
# with the value set to an empty string.
arguments[argument.lstrip("--")] = ""
Deprecated, use instead.
Returns current datetime as a dictionary of keys: year, month, day, weekday, dst (Daylight Savings Time), hour, minute, second.
Deprecated, use instead.
Returns current date as a dictionary of keys: year, month, day, weekday, dst (Daylight Savings Time).
Deprecated, use instead.
Returns current time as a dictionary of keys: hour, minute, second.
Returns the current time zone as a dictionary with the keys: bias and name.
Returns the current UNIX epoch timestamp in seconds.
Important: This is the system clock that the user can manually set. Never use this method for precise time calculation since its results are also subject to automatic adjustments by the operating system. Always use or for precise time calculation instead, since they are guaranteed to be monotonic (i.e. never decrease).
Note: To get a floating point timestamp with sub-second precision, use .
Deprecated, use instead.
Gets a dictionary of time values corresponding to the given UNIX epoch time (in seconds).
The returned Dictionary's values will be the same as , with the exception of Daylight Savings Time as it cannot be determined from the epoch.
Gets an epoch time value from a dictionary of time values.
datetime must be populated with the following keys: year, month, day, hour, minute, second.
If the dictionary is empty 0 is returned. If some keys are omitted, they default to the equivalent values for the UNIX epoch timestamp 0 (1970-01-01 at 00:00:00 UTC).
You can pass the output from directly into this function. Daylight Savings Time (dst), if present, is ignored.
Returns the epoch time of the operating system in seconds.
Returns the epoch time of the operating system in milliseconds.
Sets the game's icon using a multi-size platform-specific icon file (*.ico on Windows and *.icns on macOS).
Appropriate size sub-icons are used for window caption, taskbar/dock and window selection dialog.
Note: This method is implemented on macOS and Windows.
Sets the game's icon using an resource.
The same image is used for window caption, taskbar/dock and window selection dialog. Image is scaled as needed.
Note: This method is implemented on HTML5, Linux, macOS and Windows.
Delays execution of the current thread by usec microseconds. usec must be greater than or equal to 0. Otherwise, will do nothing and will print an error message.
Note: is a blocking way to delay code execution. To delay code execution in a non-blocking way, see . Yielding with will delay the execution of code placed below the yield without affecting the rest of the project (or editor, for s and s).
Note: When is called on the main thread, it will freeze the project and will prevent it from redrawing and registering input until the delay has passed. When using as part of an or , it will freeze the editor but won't freeze the project if it is currently running (since the project is an independent child process).
Delays execution of the current thread by msec milliseconds. msec must be greater than or equal to 0. Otherwise, will do nothing and will print an error message.
Note: is a blocking way to delay code execution. To delay code execution in a non-blocking way, see . Yielding with will delay the execution of code placed below the yield without affecting the rest of the project (or editor, for s and s).
Note: When is called on the main thread, it will freeze the project and will prevent it from redrawing and registering input until the delay has passed. When using as part of an or , it will freeze the editor but won't freeze the project if it is currently running (since the project is an independent child process).
Deprecated, use instead.
Returns the amount of time passed in milliseconds since the engine started.
Deprecated, use instead.
Returns the amount of time passed in microseconds since the engine started.
Returns the amount of time in milliseconds it took for the boot logo to appear.
Returns the host OS locale as a string of the form language_Script_COUNTRY_VARIANT@extra. If you want only the language code and not the fully specified locale from the OS, you can use .
language - 2 or 3-letter language code, in lower case.
Script - optional, 4-letter script code, in title case.
COUNTRY - optional, 2 or 3-letter country code, in upper case.
VARIANT - optional, language variant, region and sort order. Variant can have any number of underscored keywords.
extra - optional, semicolon separated list of additional key words. Currency, calendar, sort order and numbering system information.
Returns the host OS locale's 2 or 3-letter language code as a string which should be consistent on all platforms. This is equivalent to extracting the language part of the string.
This can be used to narrow down fully specified locale strings to only the "common" language code, when you don't need the additional information about country code or variants. For example, for a French Canadian user with fr_CA locale, this would return fr.
Returns the current latin keyboard variant as a String.
Possible return values are: "QWERTY", "AZERTY", "QZERTY", "DVORAK", "NEO", "COLEMAK" or "ERROR".
Note: This method is implemented on Linux, macOS and Windows. Returns "QWERTY" on unsupported platforms.
Returns the model name of the current device.
Note: This method is implemented on Android and iOS. Returns "GenericDevice" on unsupported platforms.
Returns the number of keyboard layouts.
Note: This method is implemented on Linux, macOS and Windows.
Returns active keyboard layout index.
Note: This method is implemented on Linux, macOS and Windows.
Sets active keyboard layout.
Note: This method is implemented on Linux, macOS and Windows.
Returns the ISO-639/BCP-47 language code of the keyboard layout at position index.
Note: This method is implemented on Linux, macOS and Windows.
Returns the localized name of the keyboard layout at position index.
Note: This method is implemented on Linux, macOS and Windows.
Converts a physical (US QWERTY) scancode to one in the active keyboard layout.
Note: This method is implemented on Linux, macOS and Windows.
Returns true if the host OS allows drawing.
If true, the user:// file system is persistent, so that its state is the same after a player quits and starts the game again. Relevant to the HTML5 platform, where this persistence may be unavailable.
Returns true if the engine was executed with -v (verbose stdout).
Returns true if the current host platform is using multiple threads.
Returns true if the Godot binary used to run the project is a debug export template, or when running in the editor.
Returns false if the Godot binary used to run the project is a release export template.
To check whether the Godot binary used to run the project is an export template (debug or release), use OS.has_feature("standalone") instead.
Dumps the memory allocation ringlist to a file (only works in debug).
Entry format per line: "Address - Size - Description".
Dumps all used resources to file (only works in debug).
Entry format per line: "Resource Type : Resource Location".
At the end of the file is a statistic of all used Resource Types.
Returns true if the platform has a virtual keyboard, false otherwise.
Shows the virtual keyboard if the platform has one.
The existing_text parameter is useful for implementing your own or , as it tells the virtual keyboard what text has already been typed (the virtual keyboard uses it for auto-correct and predictions).
The multiline parameter needs to be set to true to be able to enter multiple lines of text, as in .
Note: This method is implemented on Android, iOS and UWP.
Hides the virtual keyboard if it is shown, does nothing otherwise.
Returns the on-screen keyboard's height in pixels. Returns 0 if there is no keyboard or if it is currently hidden.
Shows all resources currently used by the game.
Shows all resources in the game. Optionally, the list can be written to a file by specifying a file path in tofile.
Returns the amount of static memory being used by the program in bytes (only works in debug).
Returns the maximum amount of static memory used (only works in debug).
Returns the total amount of dynamic memory used (only works in debug).
Moves the file or directory to the system's recycle bin. See also .
The method takes only global paths, so you may need to use . Do not use it for files in res:// as it will not work in exported project.
Note: If the user has disabled the recycle bin on their system, the file will be permanently deleted instead.
var file_to_remove = "user://slot1.sav"
OS.move_to_trash(ProjectSettings.globalize_path(file_to_remove))
Returns the absolute directory path where user data is written (user://).
On Linux, this is ~/.local/share/godot/app_userdata/[project_name], or ~/.local/share/[custom_name] if use_custom_user_dir is set.
On macOS, this is ~/Library/Application Support/Godot/app_userdata/[project_name], or ~/Library/Application Support/[custom_name] if use_custom_user_dir is set.
On Windows, this is %APPDATA%\Godot\app_userdata\[project_name], or %APPDATA%\[custom_name] if use_custom_user_dir is set. %APPDATA% expands to %USERPROFILE%\AppData\Roaming.
If the project name is empty, user:// falls back to res://.
Not to be confused with , which returns the global (non-project-specific) user data directory.
Returns the actual path to commonly used folders across different platforms. Available locations are specified in .
Note: This method is implemented on Android, Linux, macOS and Windows.
Note: Shared storage is implemented on Android and allows to differentiate between app specific and shared directories. Shared directories have additional restrictions on Android.
Returns the global user configuration directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the XDG_CONFIG_HOME environment variable before starting the project. See File paths in Godot projects in the documentation for more information. See also and .
Not to be confused with , which returns the project-specific user data path.
Returns the global user data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the XDG_DATA_HOME environment variable before starting the project. See File paths in Godot projects in the documentation for more information. See also and .
Not to be confused with , which returns the project-specific user data path.
Returns the global cache data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the XDG_CACHE_HOME environment variable before starting the project. See File paths in Godot projects in the documentation for more information. See also and .
Not to be confused with , which returns the project-specific user data path.
Returns a string that is unique to the device.
Note: This string may change without notice if the user reinstalls/upgrades their operating system or changes their hardware. This means it should generally not be used to encrypt persistent data as the data saved before an unexpected ID change would become inaccessible. The returned string may also be falsified using external programs, so do not rely on the string returned by for security purposes.
Note: Returns an empty string on HTML5 and UWP, as this method isn't implemented on those platforms yet.
Returns true if the OK button should appear on the left and Cancel on the right.
Shows the list of loaded textures sorted by size in memory.
Shows the number of resources loaded by the game of the given types.
Plays native video from the specified path, at the given volume and with audio and subtitle tracks.
Note: This method is only implemented on iOS.
Returns true if native video is playing.
Note: This method is only implemented on iOS.
Stops native video playback.
Note: This method is implemented on iOS.
Pauses native video playback.
Note: This method is only implemented on iOS.
Resumes native video playback.
Note: This method is implemented on iOS.
Returns the given scancode as a string (e.g. Return values: "Escape", "Shift+Escape").
See also and .
Returns true if the input scancode corresponds to a Unicode character.
Returns the scancode of the given string (e.g. "Escape").
Enables backup saves if enabled is true.
Displays a modal dialog box using the host OS' facilities. Execution is blocked until the dialog is closed.
Crashes the engine (or the editor if called within a tool script). This should only be used for testing the system's crash handler, not for any other purpose. For general error reporting, use (in order of preference) @GDScript.assert, @GDScript.push_error or . See also .
Sets the name of the current thread.
Returns the ID of the current thread. This can be used in logs to ease debugging of multi-threaded applications.
Note: Thread IDs are not deterministic and may be reused across application restarts.
Returns the ID of the main thread. See .
Note: Thread IDs are not deterministic and may be reused across application restarts.
Returns true if the feature for the given feature tag is supported in the currently running instance, depending on the platform, build etc. Can be used to check whether you're currently running a debug build, on a certain platform or arch, etc. Refer to the Feature Tags documentation for more details.
Note: Tag names are case-sensitive.
Returns the current state of the device regarding battery and power. See constants.
Note: This method is implemented on Linux, macOS and Windows.
Returns an estimate of the time left in seconds before the device runs out of battery. Returns -1 if power state is unknown.
Note: This method is implemented on Linux, macOS and Windows.
Returns the amount of battery left in the device as a percentage. Returns -1 if power state is unknown.
Note: This method is implemented on Linux, macOS and Windows.
At the moment this function is only used by AudioDriverOpenSL to request permission for RECORD_AUDIO on Android.
With this function, you can request dangerous permissions since normal permissions are automatically granted at install time in Android applications.
Note: This method is implemented on Android.
With this function, you can get the list of dangerous permissions that have been granted to the Android application.
Note: This method is implemented on Android.
Returns the total number of available tablet drivers.
Note: This method is implemented on Windows.
Returns the tablet driver name for the given index.
Note: This method is implemented on Windows.
Singleton for saving Godot-specific resource types to the filesystem.
It uses the many classes registered in the engine (either built-in or from a plugin) to save engine-specific resource data to text-based (e.g. .tres or .tscn) or binary files (e.g. .res or .scn).
Save the resource with a path relative to the scene which uses it.
Bundles external resources.
Changes the of the saved resource to match its new location.
Do not save editor-specific metadata (identified by their __editor prefix).
Save as big endian (see ).
Compress the resource on save using . Only available for binary resource types.
Take over the paths of the saved subresources (see ).
Saves a resource to disk to the given path, using a that recognizes the resource object.
The flags bitmask can be specified to customize the save behavior.
Returns OK on success.
Returns the list of extensions available for saving a resource of a given type.
A synchronization semaphore which can be used to synchronize multiple s. Initialized to zero on creation. Be careful to avoid deadlocks. For a binary version, see .
Waits for the , if its value is zero, blocks until non-zero.
Note: This method internals' can't possibly fail, but an error code is returned for backwards compatibility, which will always be OK.
Lowers the , allowing one more thread in.
Note: This method internals' can't possibly fail, but an error code is returned for backwards compatibility, which will always be OK.
Like , but won't block, so if the value is zero, fails immediately and returns ERR_BUSY. If non-zero, it returns OK to report success.
A unit of execution in a process. Can run methods on s simultaneously. The use of synchronization via or is advised if working with shared objects.
Note: Breakpoints won't break on code if it's running in a thread. This is a current limitation of the GDScript debugger.
A thread running with lower priority than normally.
A thread with a standard priority.
A thread running with higher priority than normally.
Starts a new that runs method on object instance with userdata passed as an argument. Even if no userdata is passed, method must accept one argument and it will be null. The priority of the can be changed by passing a value from the enum.
Returns OK on success, or ERR_CANT_CREATE on failure.
Returns the current 's ID, uniquely identifying it among all threads. If the is not running this returns an empty string.
Returns true if this has been started. Once started, this will return true until it is joined using . For checking if a is still executing its task, use .
Returns true if this is currently running. This is useful for determining if can be called without blocking the calling thread.
To check if a is joinable, use .
Joins the and waits for it to finish. Returns the output of the method passed to .
Should either be used when you want to retrieve the value returned from the method called by the or before freeing the instance that contains the .
To determine if this can be called without blocking the calling thread, check if is false.
Note: After the finishes joining it will be disposed. If you want to use it again you will have to create a new instance of it.