Browse docson_connect
On this page
Lifecycle event

on_connect

Runs once immediately after on_start for each script Run, using the controller family known at startup.

Syntax

Atlas Script
event on_connect() { }

Return value

See the remarks for the returned value and runtime behavior.

Remarks

Runs once immediately after on_start for each script Run, using the controller family known at startup. It is not retriggered when the controller family later changes. Controller input/output is not available here; use system.controller for the startup family and on_input for controller packets.

Examples

Inspect the controller family.atlas
event on_connect() {
    system.log(string.format("Controller at Run: {}", system.controller));
}

event on_input() {
    if (input.pressed("options")) {
        if (input.controller == controller.ps5) {
            system.log("PlayStation 5 controller");
        } else if (input.controller == controller.xb) {
            system.log("Xbox controller");
        } else {
            system.log(string.format("Controller family: {}", input.controller));
        }
    }
}
Reference details are generated from the Atlas Script schema in this documentation source snapshot. Confirm release-specific behavior in the Atlas for Windows build you use.