Signals
SignalN
Package: godot.core. Signal0 through Signal16 encode the number and types of emitted arguments. SignalN is a handle to a signal on a Godot object; declaring a JVM member alone still follows registration selection.
Operations
| Method |
Result/effect |
emit(p0, ..., pN) |
Emits arguments checked against the typed signal |
connect(callable, flags) |
Connects a compatible typed callable; returns no value |
disconnect(callable) |
Disconnects that callable |
isConnected(callable) |
Whether the callable is connected |
isValid() |
Whether the owner exists and has the signal |
hasConnections() |
Whether any connection exists |
getConnections() |
Godot connection-list dictionaries |
flags defaults to godot.core.ConnectFlags.DEFAULT. Other generated flags include DEFERRED, ONE_SHOT, and REFERENCE_COUNTED.
Method connections
connectMethod / SignalConnectors.connectMethodN connects a registered method and returns a SignalConnector. In these snippets, this is a Player instance with onHealthChanged registered and healthChanged declared as above.
MethodStringNameN takes the exact Godot name; it does not convert camelCase. Declare it once and reuse it for each connection or callable targeting the same script method. Godot-JVM already generates ...Name fields for every method on a generated Godot base class, such as Node.queueFreeName; use those fields instead of creating a MethodStringNameN yourself.
Lambda connections
A lambda connection has no registered method requirement. Java and Scala supply explicit boxed argument classes. Each helper returns a connected SignalConnector.
SignalConnector
Package: godot.extension. Holds the signal/callable pair.
| Method |
Contract |
disconnect() |
Removes the connection |
isConnected() |
Checks the connection |
isValid() |
Checks both signal and callable validity |
connect(flags) |
Connects/reconnects; returns godot.core.Error |
createUnsafe(signal, callable) |
Creates a connector without connecting it |
Kotlin can omit flags on connect; Java/Scala pass ConnectFlags.DEFAULT explicitly. Retain the connector when disconnection is required later.
Dynamic signals
Signal.createUnsafe(owner, name) creates an untyped handle and converts the name to Godot spelling. emitUnsafe(args...), connectUnsafe(callable, flags), and disconnectUnsafe(callable) operate without typed argument checking. connectUnsafe returns Godot's connection error code. The owner must actually have the named signal.