Types and conversions
Registered signatures
| Value family | Property | Function parameter / return |
|---|---|---|
| Boolean, Byte, Short, Char, Int, Long, Float, Double, String | Supported | Supported |
Dynamic Variant (Any / Object) |
Supported | Supported |
| Core Godot types | Supported | Supported |
Node or Resource subclass |
Supported | Supported |
Other godot.api.Object subclasses |
Not a supported property type | Supported |
| JVM enum | Supported | Supported |
BitField<E> |
Supported when E is an enum |
Supported |
List of enums |
Supported as an enum-list property | Not supported |
No result (Unit / void) |
Not a property value | Return only |
| Arbitrary JVM classes, JVM arrays, generic type parameters | Not supported | Not supported |
Container element types must also be representable. Any/Object does not make an arbitrary JVM instance serializable to a Godot Variant. Primitive, string, and core-type properties must not be nullable; Node and Resource references may be null. Java and Scala carry no reliable nullability information, so the build cannot check this for them: a null reaching a primitive, string, core-type or enum property, parameter or return value fails at runtime instead.
Type names
These are accepted JVM representations, including narrower numeric types; they do not imply equal range or precision.
| Godot | Kotlin |
|---|---|
| bool | Boolean |
| int (signed 64-bit) | Byte, Short, Char, Int, Long |
| float (64-bit) | Float, Double |
| String | String |
| Variant / dynamic value | Any? |
| Object reference | Node?, Resource?, or another supported class |
| Array | VariantArray<T> |
| Dictionary | Dictionary<K, V> |
| No return value | Unit |
| Godot | Java |
|---|---|
| bool | boolean / Boolean |
| int (signed 64-bit) | byte, short, char, int, long / boxed equivalents |
| float (64-bit) | float, double / boxed equivalents |
| String | String |
| Variant / dynamic value | java.lang.Object |
| Object reference | Node, Resource, or another supported class (nullable) |
| Array | VariantArray<T> |
| Dictionary | Dictionary<K, V> |
| No return value | void |
Use boxed primitives in generic arguments, such as VariantArray<Integer>. godot.api.Object is the engine base class; java.lang.Object is the dynamic Variant carrier.
| Godot | Scala |
|---|---|
| bool | Boolean |
| int (signed 64-bit) | Byte, Short, Char, Int, Long |
| float (64-bit) | Float, Double |
| String | String |
| Variant / dynamic value | Any |
| Object reference | Node, Resource, or another supported class (nullable) |
| Array | VariantArray[T] |
| Dictionary | Dictionary[K, V] |
| No return value | Unit |
Use boxed types such as Integer and java.lang.Boolean in generic arguments when registration needs concrete primitive metadata. Scala primitive generic arguments can erase to Object.
Narrower numeric types can lose range or precision when receiving Godot values. A Char is its code point to Godot, not a one-character string.
Core types
Use the same class names from godot.core in each language:
- Math:
Vector2,Vector2i,Vector3,Vector3i,Vector4,Vector4i,Rect2,Rect2i,Transform2D,Transform3D,Plane,Quaternion,AABB,Basis,Projection,Color. - Names and handles:
StringName,NodePath,RID. - Containers:
VariantArray,Dictionary,PackedByteArray,PackedInt32Array,PackedInt64Array,PackedFloat32Array,PackedFloat64Array,PackedStringArray,PackedVector2Array,PackedVector3Array,PackedVector4Array,PackedColorArray. - Callbacks:
SignalandCallable. A value coming from Godot is always the base type, so a registered parameter, return or signal argument must be declared asCallableorSignal, never as a typed variant such asSignal1orCallable0.
Copies and shared storage
Core value types read from Godot properties are copies. Mutating the copy affects the property only after assignment back. VariantArray and Dictionary share container storage with Godot, but reading a value-type element still returns a copy.
1 2 3 4 5 6 7 | |
1 2 3 4 5 6 | |
1 2 3 4 5 6 | |
The same write-back rule applies to collection elements: get, mutate, then set. Kotlin additionally provides array.mutate(index) { ... } and dictionary.mutate(key) { ... } in godot.core.
StringName and NodePath
Keep names and paths as ordinary strings while building or passing them around. Converting a String to a StringName or NodePath costs more than using the string itself. When code uses the same name or path repeatedly, convert it once with a cached helper and reuse the result.
equals and hashCode compare the Godot value, not the JVM object: two StringName or two NodePath instances holding the same name or path are equal even when they come from different calls, so both types work as keys in JVM maps and sets.
| Operation | Effect |
|---|---|
asCachedStringName |
Cached interned name; preserves spelling |
asCachedNodePath |
Cached node path; preserves spelling |
toGodotName |
Converts a member name to snake_case and returns a StringName |
1 2 3 4 5 6 7 | |
1 2 3 4 5 6 | |
1 2 3 4 5 | |
Enums and bitfields
Scala enums
Plain Scala 3 enum types are not recognized for registration. Extend java.lang.Enum[YourEnum].
A registered enum property automatically receives an Inspector dropdown. Its labels are the entry names capitalized the way GDScript does, so FIRE_BALL reads Fire Ball. Ordinary JVM enums use their ordinal as the numeric value. GodotEnum permits custom values; the numeric accessor is value in Kotlin and getValue() in Java/Scala.
A BitField<E> holds a flag mask for enum E. Ordinary enum entries use 1L << ordinal; GodotEnum entries use their explicit value as the mask. Exported bitfields support at most 32 entries. Engine bitfield wrapper types such as Control.SizeFlags cannot be used in registered properties, functions or signals; use BitField<E> with an enum.
This complete script exports one property of each kind: a regular enum dropdown, a GodotEnum dropdown with explicit values, and a BitField checkbox group.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
BitField exposes or, and, xor, contains, inv, shl, shr, and ushr. Operations return a new wrapper. The numeric mask is flag in Kotlin or getFlag() in Java/Scala. The Inspector uses the explicit GodotEnum values for its dropdown and bitfield masks.
A List of enums on a property receives an enum-list hint. It does not make JVM lists a replacement for VariantArray in registered function signatures. See property registration.