Global functions and helpers
GD
Package: godot.global. Methods are exposed as static JVM methods. Numeric operations run through the binding/JVM implementation; engine-backed operations require a running Godot runtime.
1 2 3 | |
1 2 3 | |
1 2 3 | |
Resource loading
load loads a resource at call time. path is required; use an absolute resource path such as res://player.tscn. typeHint defaults to ""; cacheMode defaults to ResourceLoader.CacheMode.REUSE. Returns the resource or null on failure. Java overloads allow omitting the optional arguments.
1 2 3 4 | |
1 2 3 4 | |
1 2 3 4 | |
There is no compile-time preload equivalent. A generic result type does not turn an incompatible resource into that type.
Logging
An exception escaping a JVM callback is logged with its stack trace. The Godot-side call returns a default value (nil for a registered function result) and the game keeps running; the remaining statements in the failed callback do not run.
These operations return no value. Except printStack(), each accepts zero or more Variant/JVM values to format.
| Method | Output |
|---|---|
print(args...) |
Godot output |
printRich(args...) |
Rich-text Godot output |
printVerbose(args...) |
Verbose output |
printErr(args...) |
Error output |
printRaw(args...) |
Raw output |
prints(args...) |
Values separated by spaces |
printt(args...) |
Values separated by tabs |
pushError(args...) |
Godot error report |
pushWarning(args...) |
Godot warning report |
printStack() |
Current JVM thread's stack trace |
Objects and shutdown
| Method | Result/effect |
|---|---|
isInstanceValid(object) |
Boolean; false for null or a deleted native object |
syncMemory() |
Requests binding memory synchronization; main thread only, other threads get an error and no sync |
callWhenClosing(callback) |
Registers a no-argument, Kotlin-Unit-returning shutdown callback |
See Objects and lifetime for language syntax and lifetime restrictions.
Strings, colors, and assertions
| Method | Contract |
|---|---|
len(value) |
Integer length for supported strings/collections/core containers; unsupported values throw IllegalArgumentException |
ord(text) |
Integer value of the first UTF-16 character; an empty string fails with an index error |
char(code) |
Converts a JVM character code to a one-character string |
Color8(r8, g8, b8, a8) |
Builds a Color by dividing integer channels by 255; Kotlin alpha default is 255 |
ColorN(name, alpha) |
Named color with alpha; Kotlin alpha default is 1f |
assert(condition, message) |
JVM assertion; message defaults to empty and assertions must be enabled to take effect |
Java cannot call methods named char or assert in source because these are Java keywords. Use Java character conversion or Java assertions. Java/Scala calls to Color8 and ColorN supply all arguments.
1 2 | |
1 2 | |
1 2 | |
Random numbers
| Method | Result/effect |
|---|---|
randf() |
Random floating-point value from Godot's generator |
randfRange(from, to) |
Floating-point range sample; bounds are single precision |
randfn(mean, deviation) |
Gaussian sample; Kotlin defaults are 0f, 1f; Java/Scala supply both |
randi() |
Random integer from Godot's generator |
randiRange(from, to) |
Integer range sample; input bounds are 32-bit integers |
randFromSeed(seed) |
kotlin.Pair<Long, Long> containing the generated integer and the generator's seed after the draw |
randomize() |
Reseeds the shared generator |
seed(seed) |
Sets its 64-bit seed |
1 2 3 | |
1 2 3 | |
1 2 3 | |
Numeric functions
The following tables list the available overloads, including return types. Angles are in radians unless a conversion function says otherwise. Overload names preserve the binding's exact spelling. These are call signatures, not declarations to paste into a script.
| Function | Overloads |
|---|---|
abs |
abs(s: Int): Intabs(s: Long): Longabs(s: Float): Floatabs(s: Double): Double |
acos |
acos(s: Float): Floatacos(s: Double): Double |
acosh |
acosh(x: Float): Floatacosh(x: Double): Double |
angleDifference |
angleDifference(from: Float, to: Float): FloatangleDifference(from: Double, to: Double): Double |
asin |
asin(s: Float): Floatasin(s: Double): Double |
asinh |
asinh(x: Float): Floatasinh(x: Double): Double |
atan |
atan(s: Float): Floatatan(s: Double): Double |
atan2 |
atan2(y: Float, x: Float): Floatatan2(y: Double, x: Double): Double |
atanh |
atanh(x: Float): Floatatanh(x: Double): Double |
bezierDerivative |
bezierDerivative(start: Float, control1: Float, control2: Float, end: Float, t: Float): FloatbezierDerivative(start: Double, control1: Double, control2: Double, end: Double, t: Double): Double |
cartesian2polar |
cartesian2polar(x: Float, y: Float): Vector2cartesian2polar(x: Double, y: Double): Vector2 |
ceil |
ceil(s: Float): Floatceil(s: Double): Double |
clamp |
clamp(value: Float, min: Float, max: Float): Floatclamp(value: Double, min: Double, max: Double): Doubleclamp(value: Float, min: Int, max: Int): Floatclamp(value: Double, min: Long, max: Long): Double |
cos |
cos(s: Float): Floatcos(s: Double): Double |
cosh |
cosh(s: Float): Floatcosh(s: Double): Double |
dbToLinear |
dbToLinear(db: Float): DoubledbToLinear(db: Double): Double |
degToRad |
degToRad(s: Float): DoubledegToRad(s: Double): Double |
ease |
ease(value: Float, curve: Float): Floatease(value: Double, curve: Double): Double |
exp |
exp(s: Float): Floatexp(s: Double): Double |
floor |
floor(s: Float): Floatfloor(s: Double): Double |
floori |
floori(s: Float): Intfloori(s: Double): Int |
fmod |
fmod(a: Float, b: Float): Floatfmod(a: Double, b: Double): Double |
fposmod |
fposmod(arg0: Float, arg1: Float): Floatfposmod(arg0: Double, arg1: Double): Double |
inverseLerp |
inverseLerp(from: Float, to: Float, weight: Float): FloatinverseLerp(from: Double, to: Double, weight: Double): Double |
isEqualApprox |
isEqualApprox(a: Float, b: Float): BooleanisEqualApprox(a: Double, b: Double): Boolean |
isFinite |
isFinite(s: Float): BooleanisFinite(s: Double): Boolean |
isInf |
isInf(s: Float): BooleanisInf(s: Double): Boolean |
isNan |
isNan(s: Float): BooleanisNan(s: Double): Boolean |
isSame |
isSame(a: Any, b: Any): Boolean |
isZeroApprox |
isZeroApprox(s: Float): BooleanisZeroApprox(s: Double): Boolean |
lerp |
lerp(from: Int, to: Int, weight: Float): Floatlerp(from: Long, to: Long, weight: Double): Doublelerp(from: Float, to: Float, weight: Float): Floatlerp(from: Double, to: Double, weight: Double): Doublelerp(from: Color, to: Color, weight: Float): Colorlerp(from: Color, to: Color, weight: Double): Colorlerp(from: Vector2, to: Vector2, weight: Float): Vector2lerp(from: Vector2, to: Vector2, weight: Double): Vector2lerp(from: Vector3, to: Vector3, weight: Float): Vector3lerp(from: Vector3, to: Vector3, weight: Double): Vector3 |
lerpAngle |
lerpAngle(arg0: Float, arg1: Float, arg2: Float): FloatlerpAngle(arg0: Double, arg1: Double, arg2: Double): Double |
linearToDb |
linearToDb(nrg: Float): DoublelinearToDb(nrg: Double): Double |
log |
log(s: Float): Floatlog(s: Double): Double |
max |
max(a: Int, b: Int): Intmax(a: Long, b: Long): Longmax(a: Float, b: Float): Floatmax(a: Double, b: Double): Double |
min |
min(a: Int, b: Int): Intmin(a: Long, b: Long): Longmin(a: Float, b: Float): Floatmin(a: Double, b: Double): Double |
mod |
mod(a: Int, b: Int): Intmod(a: Long, b: Long): Long |
moveToward |
moveToward(from: Int, to: Int, delta: Int): IntmoveToward(from: Long, to: Long, delta: Long): LongmoveToward(from: Float, to: Float, delta: Float): FloatmoveToward(from: Double, to: Double, delta: Double): Double |
nearestPo2 |
nearestPo2(arg0: Int): IntnearestPo2(arg0: Long): LongnearestPo2(arg0: Float): FloatnearestPo2(arg0: Double): Double |
polarToCartesian |
polarToCartesian(r: Float, th: Float): Vector2polarToCartesian(r: Double, th: Double): Vector2 |
posmod |
posmod(arg0: Int, arg1: Int): Intposmod(arg0: Long, arg1: Long): Long |
pow |
pow(base: Float, exp: Float): Floatpow(base: Double, exp: Double): Double |
radToDeg |
radToDeg(rad: Float): FloatradToDeg(rad: Double): Double |
remap |
remap(value: Float, istart: Float, istop: Float, ostart: Float, ostop: Float): Floatremap(value: Double, istart: Double, istop: Double, ostart: Double, ostop: Double): Double |
rotateToward |
rotateToward(from: Float, to: Float, delta: Float): FloatrotateToward(from: Double, to: Double, delta: Double): Double |
round |
round(s: Float): Floatround(s: Double): Double |
sign |
sign(s: Float): Floatsign(s: Double): Double |
sin |
sin(s: Float): Floatsin(s: Double): Double |
sinh |
sinh(s: Float): Floatsinh(s: Double): Double |
smoothstep |
smoothstep(from: Float, to: Float, weight: Float): Floatsmoothstep(from: Double, to: Double, weight: Double): Double |
snapped |
snapped(x: Int, step: Int): Intsnapped(x: Long, step: Long): Longsnapped(x: Float, step: Float): Floatsnapped(x: Double, step: Double): Double |
snappedf |
snappedf(x: Float, step: Float): Floatsnappedf(x: Double, step: Double): Double |
snappedi |
snappedi(x: Float, step: Int): Intsnappedi(x: Double, step: Long): Long |
sqrt |
sqrt(s: Float): Floatsqrt(s: Double): Double |
stepDecimals |
stepDecimals(step: Float): IntstepDecimals(step: Double): Int |
tan |
tan(s: Float): Floattan(s: Double): Double |
tanh |
tanh(s: Float): Floattanh(s: Double): Double |
wrapf |
wrapf(value: Float, min: Float, max: Float): Floatwrapf(value: Double, min: Double, max: Double): Double |
wrapi |
wrapi(value: Int, min: Int, max: Int): Intwrapi(value: Long, min: Long, max: Long): Long |
| Function | Overloads |
|---|---|
abs |
int abs(int s)long abs(long s)float abs(float s)double abs(double s) |
acos |
float acos(float s)double acos(double s) |
acosh |
float acosh(float x)double acosh(double x) |
angleDifference |
float angleDifference(float from, float to)double angleDifference(double from, double to) |
asin |
float asin(float s)double asin(double s) |
asinh |
float asinh(float x)double asinh(double x) |
atan |
float atan(float s)double atan(double s) |
atan2 |
float atan2(float y, float x)double atan2(double y, double x) |
atanh |
float atanh(float x)double atanh(double x) |
bezierDerivative |
float bezierDerivative(float start, float control1, float control2, float end, float t)double bezierDerivative(double start, double control1, double control2, double end, double t) |
cartesian2polar |
Vector2 cartesian2polar(float x, float y)Vector2 cartesian2polar(double x, double y) |
ceil |
float ceil(float s)double ceil(double s) |
clamp |
float clamp(float value, float min, float max)double clamp(double value, double min, double max)float clamp(float value, int min, int max)double clamp(double value, long min, long max) |
cos |
float cos(float s)double cos(double s) |
cosh |
float cosh(float s)double cosh(double s) |
dbToLinear |
double dbToLinear(float db)double dbToLinear(double db) |
degToRad |
double degToRad(float s)double degToRad(double s) |
ease |
float ease(float value, float curve)double ease(double value, double curve) |
exp |
float exp(float s)double exp(double s) |
floor |
float floor(float s)double floor(double s) |
floori |
int floori(float s)int floori(double s) |
fmod |
float fmod(float a, float b)double fmod(double a, double b) |
fposmod |
float fposmod(float arg0, float arg1)double fposmod(double arg0, double arg1) |
inverseLerp |
float inverseLerp(float from, float to, float weight)double inverseLerp(double from, double to, double weight) |
isEqualApprox |
boolean isEqualApprox(float a, float b)boolean isEqualApprox(double a, double b) |
isFinite |
boolean isFinite(float s)boolean isFinite(double s) |
isInf |
boolean isInf(float s)boolean isInf(double s) |
isNan |
boolean isNan(float s)boolean isNan(double s) |
isSame |
boolean isSame(java.lang.Object a, java.lang.Object b) |
isZeroApprox |
boolean isZeroApprox(float s)boolean isZeroApprox(double s) |
lerp |
float lerp(int from, int to, float weight)double lerp(long from, long to, double weight)float lerp(float from, float to, float weight)double lerp(double from, double to, double weight)Color lerp(Color from, Color to, float weight)Color lerp(Color from, Color to, double weight)Vector2 lerp(Vector2 from, Vector2 to, float weight)Vector2 lerp(Vector2 from, Vector2 to, double weight)Vector3 lerp(Vector3 from, Vector3 to, float weight)Vector3 lerp(Vector3 from, Vector3 to, double weight) |
lerpAngle |
float lerpAngle(float arg0, float arg1, float arg2)double lerpAngle(double arg0, double arg1, double arg2) |
linearToDb |
double linearToDb(float nrg)double linearToDb(double nrg) |
log |
float log(float s)double log(double s) |
max |
int max(int a, int b)long max(long a, long b)float max(float a, float b)double max(double a, double b) |
min |
int min(int a, int b)long min(long a, long b)float min(float a, float b)double min(double a, double b) |
mod |
int mod(int a, int b)long mod(long a, long b) |
moveToward |
int moveToward(int from, int to, int delta)long moveToward(long from, long to, long delta)float moveToward(float from, float to, float delta)double moveToward(double from, double to, double delta) |
nearestPo2 |
int nearestPo2(int arg0)long nearestPo2(long arg0)float nearestPo2(float arg0)double nearestPo2(double arg0) |
polarToCartesian |
Vector2 polarToCartesian(float r, float th)Vector2 polarToCartesian(double r, double th) |
posmod |
int posmod(int arg0, int arg1)long posmod(long arg0, long arg1) |
pow |
float pow(float base, float exp)double pow(double base, double exp) |
radToDeg |
float radToDeg(float rad)double radToDeg(double rad) |
remap |
float remap(float value, float istart, float istop, float ostart, float ostop)double remap(double value, double istart, double istop, double ostart, double ostop) |
rotateToward |
float rotateToward(float from, float to, float delta)double rotateToward(double from, double to, double delta) |
round |
float round(float s)double round(double s) |
sign |
float sign(float s)double sign(double s) |
sin |
float sin(float s)double sin(double s) |
sinh |
float sinh(float s)double sinh(double s) |
smoothstep |
float smoothstep(float from, float to, float weight)double smoothstep(double from, double to, double weight) |
snapped |
int snapped(int x, int step)long snapped(long x, long step)float snapped(float x, float step)double snapped(double x, double step) |
snappedf |
float snappedf(float x, float step)double snappedf(double x, double step) |
snappedi |
int snappedi(float x, int step)long snappedi(double x, long step) |
sqrt |
float sqrt(float s)double sqrt(double s) |
stepDecimals |
int stepDecimals(float step)int stepDecimals(double step) |
tan |
float tan(float s)double tan(double s) |
tanh |
float tanh(float s)double tanh(double s) |
wrapf |
float wrapf(float value, float min, float max)double wrapf(double value, double min, double max) |
wrapi |
int wrapi(int value, int min, int max)long wrapi(long value, long min, long max) |
| Function | Overloads |
|---|---|
abs |
abs(s: Int): Intabs(s: Long): Longabs(s: Float): Floatabs(s: Double): Double |
acos |
acos(s: Float): Floatacos(s: Double): Double |
acosh |
acosh(x: Float): Floatacosh(x: Double): Double |
angleDifference |
angleDifference(from: Float, to: Float): FloatangleDifference(from: Double, to: Double): Double |
asin |
asin(s: Float): Floatasin(s: Double): Double |
asinh |
asinh(x: Float): Floatasinh(x: Double): Double |
atan |
atan(s: Float): Floatatan(s: Double): Double |
atan2 |
atan2(y: Float, x: Float): Floatatan2(y: Double, x: Double): Double |
atanh |
atanh(x: Float): Floatatanh(x: Double): Double |
bezierDerivative |
bezierDerivative(start: Float, control1: Float, control2: Float, end: Float, t: Float): FloatbezierDerivative(start: Double, control1: Double, control2: Double, end: Double, t: Double): Double |
cartesian2polar |
cartesian2polar(x: Float, y: Float): Vector2cartesian2polar(x: Double, y: Double): Vector2 |
ceil |
ceil(s: Float): Floatceil(s: Double): Double |
clamp |
clamp(value: Float, min: Float, max: Float): Floatclamp(value: Double, min: Double, max: Double): Doubleclamp(value: Float, min: Int, max: Int): Floatclamp(value: Double, min: Long, max: Long): Double |
cos |
cos(s: Float): Floatcos(s: Double): Double |
cosh |
cosh(s: Float): Floatcosh(s: Double): Double |
dbToLinear |
dbToLinear(db: Float): DoubledbToLinear(db: Double): Double |
degToRad |
degToRad(s: Float): DoubledegToRad(s: Double): Double |
ease |
ease(value: Float, curve: Float): Floatease(value: Double, curve: Double): Double |
exp |
exp(s: Float): Floatexp(s: Double): Double |
floor |
floor(s: Float): Floatfloor(s: Double): Double |
floori |
floori(s: Float): Intfloori(s: Double): Int |
fmod |
fmod(a: Float, b: Float): Floatfmod(a: Double, b: Double): Double |
fposmod |
fposmod(arg0: Float, arg1: Float): Floatfposmod(arg0: Double, arg1: Double): Double |
inverseLerp |
inverseLerp(from: Float, to: Float, weight: Float): FloatinverseLerp(from: Double, to: Double, weight: Double): Double |
isEqualApprox |
isEqualApprox(a: Float, b: Float): BooleanisEqualApprox(a: Double, b: Double): Boolean |
isFinite |
isFinite(s: Float): BooleanisFinite(s: Double): Boolean |
isInf |
isInf(s: Float): BooleanisInf(s: Double): Boolean |
isNan |
isNan(s: Float): BooleanisNan(s: Double): Boolean |
isSame |
isSame(a: Any, b: Any): Boolean |
isZeroApprox |
isZeroApprox(s: Float): BooleanisZeroApprox(s: Double): Boolean |
lerp |
lerp(from: Int, to: Int, weight: Float): Floatlerp(from: Long, to: Long, weight: Double): Doublelerp(from: Float, to: Float, weight: Float): Floatlerp(from: Double, to: Double, weight: Double): Doublelerp(from: Color, to: Color, weight: Float): Colorlerp(from: Color, to: Color, weight: Double): Colorlerp(from: Vector2, to: Vector2, weight: Float): Vector2lerp(from: Vector2, to: Vector2, weight: Double): Vector2lerp(from: Vector3, to: Vector3, weight: Float): Vector3lerp(from: Vector3, to: Vector3, weight: Double): Vector3 |
lerpAngle |
lerpAngle(arg0: Float, arg1: Float, arg2: Float): FloatlerpAngle(arg0: Double, arg1: Double, arg2: Double): Double |
linearToDb |
linearToDb(nrg: Float): DoublelinearToDb(nrg: Double): Double |
log |
log(s: Float): Floatlog(s: Double): Double |
max |
max(a: Int, b: Int): Intmax(a: Long, b: Long): Longmax(a: Float, b: Float): Floatmax(a: Double, b: Double): Double |
min |
min(a: Int, b: Int): Intmin(a: Long, b: Long): Longmin(a: Float, b: Float): Floatmin(a: Double, b: Double): Double |
mod |
mod(a: Int, b: Int): Intmod(a: Long, b: Long): Long |
moveToward |
moveToward(from: Int, to: Int, delta: Int): IntmoveToward(from: Long, to: Long, delta: Long): LongmoveToward(from: Float, to: Float, delta: Float): FloatmoveToward(from: Double, to: Double, delta: Double): Double |
nearestPo2 |
nearestPo2(arg0: Int): IntnearestPo2(arg0: Long): LongnearestPo2(arg0: Float): FloatnearestPo2(arg0: Double): Double |
polarToCartesian |
polarToCartesian(r: Float, th: Float): Vector2polarToCartesian(r: Double, th: Double): Vector2 |
posmod |
posmod(arg0: Int, arg1: Int): Intposmod(arg0: Long, arg1: Long): Long |
pow |
pow(base: Float, exp: Float): Floatpow(base: Double, exp: Double): Double |
radToDeg |
radToDeg(rad: Float): FloatradToDeg(rad: Double): Double |
remap |
remap(value: Float, istart: Float, istop: Float, ostart: Float, ostop: Float): Floatremap(value: Double, istart: Double, istop: Double, ostart: Double, ostop: Double): Double |
rotateToward |
rotateToward(from: Float, to: Float, delta: Float): FloatrotateToward(from: Double, to: Double, delta: Double): Double |
round |
round(s: Float): Floatround(s: Double): Double |
sign |
sign(s: Float): Floatsign(s: Double): Double |
sin |
sin(s: Float): Floatsin(s: Double): Double |
sinh |
sinh(s: Float): Floatsinh(s: Double): Double |
smoothstep |
smoothstep(from: Float, to: Float, weight: Float): Floatsmoothstep(from: Double, to: Double, weight: Double): Double |
snapped |
snapped(x: Int, step: Int): Intsnapped(x: Long, step: Long): Longsnapped(x: Float, step: Float): Floatsnapped(x: Double, step: Double): Double |
snappedf |
snappedf(x: Float, step: Float): Floatsnappedf(x: Double, step: Double): Double |
snappedi |
snappedi(x: Float, step: Int): Intsnappedi(x: Double, step: Long): Long |
sqrt |
sqrt(s: Float): Floatsqrt(s: Double): Double |
stepDecimals |
stepDecimals(step: Float): IntstepDecimals(step: Double): Int |
tan |
tan(s: Float): Floattan(s: Double): Double |
tanh |
tanh(s: Float): Floattanh(s: Double): Double |
wrapf |
wrapf(value: Float, min: Float, max: Float): Floatwrapf(value: Double, min: Double, max: Double): Double |
wrapi |
wrapi(value: Int, min: Int, max: Int): Intwrapi(value: Long, min: Long, max: Long): Long |
Numeric behavior
| Family | Behavior |
|---|---|
abs, min, max, clamp, sign |
Absolute value, extrema, range clamp, sign |
acos, asin, atan, atan2, sin, cos, tan |
Trigonometric functions |
asinh, acosh, atanh, sinh, cosh, tanh |
Hyperbolic functions |
ceil, floor, floori, round |
Rounding; round rounds halfway cases away from zero and floori returns a 32-bit integer |
exp, log, pow, sqrt |
Exponential, natural logarithm, power, square root |
degToRad, radToDeg |
Degree/radian conversion |
angleDifference, lerpAngle, rotateToward |
Wrapped angular difference/interpolation/movement |
lerp, inverseLerp, remap |
Linear interpolation, inverse weight, interval mapping |
moveToward |
Moves toward the target without overshooting |
ease, smoothstep, bezierDerivative |
Easing, smooth interpolation, cubic Bezier derivative |
mod, fmod |
JVM remainder |
posmod, fposmod |
Sign-adjusted modulus |
snapped, snappedf, snappedi, stepDecimals |
Step snapping and decimal precision helpers |
wrapi, wrapf |
Wrap into [min, max); same formulas as the engine's Math::wrapi and Math::wrapf |
cartesian2polar, polarToCartesian |
Coordinate conversion; the latter returns (r * cos(angle), r * sin(angle)) |
nearestPo2 |
Nearest upper power-of-two helper |
dbToLinear, linearToDb |
Decibel/linear conversion |
isEqualApprox, isZeroApprox |
Binding approximate comparisons |
isFinite, isInf, isNan |
Floating-point classification |
isSame |
JVM equality (== in the Kotlin implementation), not a native pointer comparison |
Other binding helpers
| API | Reference |
|---|---|
| String-name and node-path conversions; collection mutation | Types and conversions |
asStatic / ObjectUtils.asStatic |
Objects and lifetime |
connectMethod, connectLambda, SignalConnectors |
Signals |
methodCallableN, lambdaCallableN, asCallable |
Callables |
godotCoroutine, await and dispatchers |
Coroutines |