logo
By Lawrence

5 minutes

Fly the Ship

The whole chain is built — intent, thrust down the nose, velocity, pose, model — and it reads zero at the first link. Press every key on the board and the falcon doesn't twitch. Nothing in this world has so much as heard of the keyboard.

Three components close that gap, and the shape of the fix is the interesting part. Two of them are input sources that know nothing about ships; the third turns their events into a stick deflection. The falcon never sees a keycode.

Add the two input sources to World

KeyboardInput and MouseInput are singleton sources, so they go on World — the first components that entity has carried. PlayerFlightInput marks the ship those sources fly, and joins Player:

"World": {
  "tags": ["world"],
  "components": {
    "KeyboardInput": {},
    "MouseInput": {}
  }
}
"PlayerFlightInput": { "throttleRate": 1.4 }

Both sources take empty braces — their defaults are the whole configuration. MouseInput defaults to requirePointerLock: true and clickToLock: true, which matters in a moment.

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search