Builtin Library
README.md
WASDInput
Action-to-input-bus driver. Reads the move axis and jump action
each frame, remaps move to the active viewport camera's
forward/right basis (via camera.main() + entity(camId).transform.forward),
and writes the resulting world-space horizontal velocity to a target
component's input fields:
target.inputX,target.inputZ— world-space velocity × speedtarget.inputJump— boolean, true while the jump action is held
Defaults to writing to CharacterController on the same entity, but
the field names are the contract — any component that exposes
inputX/inputZ/inputJump is a valid sink (vehicles, hovercraft,
custom CCs).
Why generic
Independent of which camera is active and independent of the visual layer:
- Works with any camera (third-person, top-down, FPS, fixed, vehicle).
- Works with no camera (falls back to world-axis WASD).
- Works without
Locomotionor any animation system — CC moves, visualization is opt-in. - Works without a follow rig —
camera.main()is the seam, not a specific camera component.
Public fields
| Field | Default | Purpose |
|---|---|---|
speed | 5.0 | Multiplier on the unit-length input vector |
targetComponent | "CharacterController" | Component to write inputX/inputZ/inputJump onto |
A custom control scheme is authored as an inputMap that rebinds the
move axis and jump action — not per-instance key fields on this
component.
Example
-- Player with CC + WASDInput + any camera
entity(playerId).component.add("CharacterController")
entity(playerId).component.add("WASDInput")
-- Active viewport camera (any kind)
local cam = entity.spawn("cam", { parent = playerId })
cam.component.add("Camera", { fov = 60, priority = 0 })
cam.component.add("orbital_follow", { follow = playerId })
-- Press W → CC.inputX/inputZ are written camera-relative each frame
-- → CC translates the body → MovementState reports velocity →
-- (optional) Locomotion rotates the visible mesh + plays anims.