Skip to main content

Object

Inherits: Base class for all other classes

Description

Base class for all other classes in the engine. An advanced Variant type. All classes in the engine inherit from Object. Each class may define new properties, methods or signals, which are available to all inheriting classes.

Key Methods

free

void free()
Deletes the object from memory. Pre-existing references to the object become invalid.

call

Variant call(method: StringName, ...)
Calls the method on the object and returns the result. Supports a variable number of arguments.
method
StringName
The name of the method to call

connect

Error connect(signal: StringName, callable: Callable, flags: int = 0)
Connects a signal by name to a callable. Returns ERR_INVALID_PARAMETER if the signal is already connected.
signal
StringName
The signal name to connect
callable
Callable
The callable to connect to the signal

get

Variant get(property: StringName)
Returns the Variant value of the given property. Returns null if the property does not exist.

set

void set(property: StringName, value: Variant)
Assigns value to the given property. If the property does not exist or types don’t match, nothing happens.

Signals

property_list_changed()

Emitted when property list changes.

Example Usage

var my_object = Object.new()
my_object.set("custom_property", 42)
var value = my_object.get("custom_property")
print(value)  # Prints: 42

# Connect to a signal
my_object.connect("property_list_changed", func(): print("Properties changed"))

Build docs developers (and LLMs) love