First-person shooter
site/media/lessons/capstones-batch.lesson.ts (5 steps) The fps example (packages/editor/template/src/examples/fps/) is a pointer-lock first-person
shooter: WASD movement, jumping, and throwable physics balls with a hold-to-charge
mechanic, plus pushable crates.
Run it
Section titled “Run it”-
Open the FPS scene. Load
examples/scenes/fps.vscn.json.
The FPS arena. -
Enter play mode. Press Play to boot the runtime.
Play mode. -
Click to lock the pointer and look around. Clicking the canvas requests pointer lock; mouse movement then drives the first-person camera. (
Escreleases the pointer.)
Pointer-lock mouse look. -
Throw a ball with a click. A click throws a dynamic physics ball (hold to charge for more power); balls collide with and knock around the crates.
Throwable dynamic physics. -
Stop play mode. Press Stop (or
Escape) to return to editing.
How it works
Section titled “How it works”Movement and camera live in GameComponents declared in the scene file (FPSController,
FPSCamera). The ball pool, hold-to-charge/throw logic, audio, and HUD are wired in the
example’s setup() as runtime infrastructure, finding the player via queryByComponent.
Recap
New functionality
- Ran the FPS and captured the pointer
- Looked around in first person
- Threw physics balls and hit crates
New concepts & skills
- Pointer lock + mouse delta drive a first-person camera
- Throwables are dynamic Rapier bodies
- Player movement/camera are GameComponents; spawning is setup infrastructure
Next lesson → Capstone: Vehicle