logo

Babylon.js Market

By Lawrence

5 minutes

TL;DRKeyboardInput and PlayerFlightInput read your held keys and fill the ship's flight intent every frame. Now you fly the falcon from the keyboard, instead of typing the throttle into JSON by hand. New here: the input layer that turns keys into intent. The ship needs a live pilot before the next lesson's chase camera has anything to follow.

Catching up?

Dropping in at this lesson? One command reinstalls the library components the build uses so far and writes the scene as it stood at the end of the previous lesson to public/scenes/WingmanFlight1-lesson-5/scene.json:

bjs download scene WingmanFlight1-lesson-5 --all

Copy that scene.json over your src/scenes/wingman.json and you are caught up to the start of this lesson.

Last lesson you built the whole flight law, but you never got to fly it. FlightIntent → thrust along the nose → Velocity6DOF → the pose → the model is wired from end to end. The problem is that the intent reads all zeros. So far, the only way to move the falcon has been to type throttle: 1 into the JSON and reload. Press a key and nothing happens. Nothing in the world is listening to the keyboard yet.

Two components close that gap. One turns raw browser key events into bus events. The other reads those events and fills FlightIntent every frame. Splitting the work this way has a payoff. The same keyboard feed can later drive a menu or a second ship. The falcon only ever sees intent, never a keycode.

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