Properties and functions
Properties
Use @Export to edit script properties in the Inspector.
The following Player fields show common exportable types. They use Export from godot.annotation, Node and Texture2D from godot.api, and the containers and Vector2 from godot.core.
Initial values become Inspector defaults. Assign the target node and texture resource in the Inspector; Texture2D is a Resource subclass. Exported core-type fields need an initial value or the build fails.
Read Inspector values in _ready
Saved Inspector values are applied after construction. Read them in _ready().
Enum dropdown
Declare a property whose type is an enum:
For ranges, file pickers, and other controls, choose a property hint.
Functions
The example includes an ordinary callable alongside two Godot callbacks.
Overrides of Godot callbacks need no extra annotation with the guide's default settings. Godot calls them according to the node lifecycle; use that page for the callback list.
Organising exports
Use @Category, @Group, and @Subgroup on the first property in a section. A category is the top-level section, a group is within a category, and a subgroup is within a group. They create Inspector markers before the annotated property; they do not change its type hint.
| Annotation |
Parameters |
@Category(name) |
name: the category label shown in the Inspector. |
@Group(name, prefix = "") |
name: the group label. prefix: optional filter for following properties whose Godot names start with it; when omitted, it defaults to name with its first letter lowercased. |
@Subgroup(name, prefix = "") |
name: the subgroup label. prefix: optional filter for following properties whose Godot names start with it; when omitted, it defaults to name with its first letter lowercased. |
Write prefix in the same casing as your source property names. It is converted to the snake_case Godot property name automatically; for example, movementGround matches movementGroundSpeed, which Godot receives as movement_ground_speed.
| @Script
class Player : Node() {
@Category("Player")
@Group("Movement") // Defaults to the `movement` prefix.
@Subgroup("Ground", "movementGround")
var movementGroundSpeed: Float = 5f
@Export
var movementGroundAcceleration: Float = 10f
}
|