# Start a Godot game

A minimal Godot 4 project with two phone players, a QR texture, movement, aiming and score feedback. The real Godot add-on receives input and sends views, public state, cues and rumble. Node supplies the local host. No engine assets or binaries are checked in.

**Tested:** Godot 4.7.2 on macOS arm64, using headless desktop execution and two SDK `Session` phones. QR texture decoding, both sticks, score, feedback messages and seat recovery passed. Native window rendering, exported builds, Windows, Linux, Steam Deck and browser exports are untested.

## Contents

- [Install and run](#install-and-run)
- [See phone input](#see-phone-input)
- [Check the integration](#check-the-integration)
- [Ship the host with the game](#ship-the-host-with-the-game)

## Install and run

Use the unpacked SDK archive, or a source checkout after `npm ci`. Use Node 22 or newer and installed **Godot 4.7.2** on macOS or Linux. Linux is an intended launcher target; it has not been tested. From the SDK root:

```sh
node examples/godot-local/server.mjs
```

This launches a Godot window. Use `--headless` for a display-free run. Set `GODOT_BIN` if the installed executable is not named `godot`. The launcher copies this small project and `integrations/godot/addons/controller_plus` to a scratch directory. The explicit autoload is already in `project.godot`:

```ini
[autoload]
ControllerPlus="*res://addons/controller_plus/controller_hub.gd"
```

The launcher gives only the authorized Godot process `CONTROLLER_PLUS_ENDPOINT`, `CONTROLLER_PLUS_ROOM`, `CONTROLLER_PLUS_HOST_TOKEN` and `CONTROLLER_PLUS_ORIGIN` through its environment. Do not put credentials in the scene or project settings. `game.gd` downloads `/qr.png`, decodes it into an `Image`, creates an `ImageTexture`, and reloads it after invitation changes.

## See phone input

For phones on the same Wi-Fi, replace this example IP with the computer's reachable address:

```sh
PUBLIC_ORIGIN=http://192.168.1.20:49704 node examples/godot-local/server.mjs
```

Scan the QR in the Godot window or open [the local QR lobby](http://127.0.0.1:49704/) on the host computer. Open the advertised LAN URL for the shared display. The web scene is an SVG emitted by the running GDScript; the native window draws the same player positions and its QR texture. Left stick moves, right stick aims, and the bottom face button scores and sends a cue plus rumble. Press Esc in the Godot window to quit.

Enter a name and tap **Play** on each phone. Moving one phone's left stick should move only its matching dot; the bottom face button should increase that dot's score.

## Check the integration

```sh
node --test examples/godot-local/test.mjs
```

The test runs **one headless Godot**, with two SDK `Session` phones. It checks QR texture decoding, both sticks, separate players, feedback commands/results, leave, stable-ID resume with score retention, removal and refreshed invitations. Protocol phones acknowledge output as `unavailable` because they have no hardware. Optional screenshot passes start Chrome only after Godot has stopped.

The Node lifecycle handlers cover `join`/`resumed`, `leave`, `removed`, `invitation` and `feedback-result`. GDScript uses roster snapshots and the add-on's joined/resumed/left/removed, invitation and receipt signals. Type `remove p1` in the terminal to free a seat. Ctrl+C closes Godot, its staged files, the host and HTTP(S) server.

See [shared setup](local-setup.md) for scratch paths, addresses and trusted HTTPS for iPhone motion. This project uses touch gamepads, so sensors and HTTPS are optional. Native engine clients must trust the same TLS issuer. Native window rendering, real Wi-Fi phones, camera scanning, sensors and physical feedback need device checks; the headless test does not establish those.

The gamepad view has `id: "godot-controls"` and movement, aim and score captions. The copied add-on negotiates SDK extensions. Use `input_received` and `clock` for local input times, `status` for motion, `view_result` for phone diagnostics and `patch_surface` for display updates. See the [Godot API](integrations.md#godot-4).

## Ship the host with the game

This launcher starts Node and Godot together. The exported game still needs a running `ControllerHost`; the add-on does not create one. Package and supervise a matching host, or operate your own reachable server. Send its host credentials only to the authorized game process. Start it before connecting the add-on, and close both processes on exit. A host restart creates a new room and invitation. See [Ship a game](shipping.md) before choosing your release setup.

[All start pages](index.md) · [Search developer docs](search.md) · [Ship a game](shipping.md)
