Godot Quick Reference
This page describes some Godot classes and methods
that may be useful for building an Arena agent. The information here
is current as of Godot 4.3. For more information, see the full
library documentation.
Class index
@GDScript
@GlobalScope
Array
Geometry2D
Vector2
@GDScript
Core built-in GDScript constants and functions.
-
- INF = inf
-
Positive floating-point infinity.
-
PI = 3.14159...
-
The constant π.
@GlobalScope
Global constants and functions.
-
- float absf(x: float)
-
Return the absolute value of x.
-
float maxf(a: float, b: float)
-
Return the maximum of two float values.
-
float minf(a: float, b: float)
-
Return the minimum of two float values.
-
void print(…)
-
Print one or more values to the console.
-
float signf(x: float)
-
Return -1.0 if x is negative, +1.0 if x is positive, or 0.0 if it is
zero.
-
String str(…)
-
Convert a value of any type to a string.
Array
A dynamic array, similar to a Python list.
-
- void append(value: Variant)
-
Append a value to an array.
-
void duplicate()
-
Return a new copy of an array.
-
void fill(value: Variant)
-
Assign the given value to all array elements.
-
Variant pop_back()
-
Remove and return the last array element.
-
Variant pop_front()
-
Remove and return the first array element.
-
void remove_at(index: int)
-
Remove the element at the given index. All following elements will
shift backward.
-
int resize(size: int)
-
Resize an array to have the given number of elements. If the array
is expanded, new default elements will be added; these depend on the
array's type, but will usually be null.
-
int size()
-
Return the length of an Array.
-
Array slice(begin: int, end: int = 2147483647)
-
Return a Array containing a copy of this Array's elements from index
'begin' (inclusive) to 'end' (exclusive). If 'end' is omitted, the
slice contains all elements through the end of this Array.
Geometry2D
A class containing geometry utility methods.
-
- Vector2 get_closest_point_to_segment(point:
Vector2, s1: Vector2, s2: Vector2)
-
Return the point on the line segment (s1, s2) that is closest to the
given point.
-
PackedVector2Array get_closest_points_between_segments(p1: Vector2,
q1: Vector2, p2: Vector2, q2: Vector2)
-
Given line segments (p1, q1) and (p2, q2), find the points on the
segments that are closest to each other. Returns a
PackedVector2Array of length 2 containing the point on (p1, q1) and
the accompanying point on (p2, q2).
-
bool is_point_in_polygon(point: Vector2, polygon:
PackedVector2Array)
-
Return true if the given point is inside the given polygon or is on
its boundary.
Vector2
A 2-dimensional vector. This class is also used to
represent points in two dimensions.
The '+
' and '-
'
operators perform vector addition and subtraction. The '*
'
and '/
' operators will multiply or
divide a vector by a scalar.
constructors
-
- Vector2(float x, float y)
-
Construct a Vector2.
-
static Vector2 from_angle(angle: float)
-
Construct a unit vector rotated to the given angle in radians.
attributes
-
- float x
-
The x-coordinate.
-
float y
-
The y-coordinate.
methods
-
- float angle()
-
Return this vector's angle with respect to the positive X axis.
-
float angle_to(to: Vector2)
-
Return the angle in radians between this vector and the given
vector.
-
float distance_to(to: Vector2)
-
Return the distance between this point and another point.
-
float length()
-
Return the length of this vector.
-
Vector2 normalized()
-
Return a vector scaled to unit length.
-
Vector2 rotated(angle: float)
-
Return the result of rotating this vector by the given angle in
radians.
constants
-
- DOWN
-
The constant vector (0, 1).
-
LEFT
-
The constant vector (-1, 0).
-
RIGHT
-
The constant vector (1, 0).
-
UP
-
The constant vector (0, -1).
-
ZERO
-
The constant vector (0, 0).