AutoRunnerProjectile
Pooled rounds for a road war, from a tracer bullet to a falling bomb.
What it does
A round is a pooled entity with a MeshPrimitive and an AutoRunnerProjectile. AutoRunnerProjectileSystem moves it, steers a missile at its target, drops a bomb, and checks the line the round travelled this frame against everything it may hurt.
| Kind | How it flies |
|---|---|
bullet | straight and fast; stopped by bulletproof armour |
shell | slower pellets a Gunner fires sideways |
missile | speeds up and turns toward its quarry at turnRate; bursts |
bomb | falls under gravity; bursts on the road |
Use it in a scene
A scene is just data — a list of entities, each with its components. At startup the SceneLoader turns this JSON into a live world; edit the file and reload to rebuild it.
Build it from scratch with the bjs CLI:
- 1Scaffold a project
World, renderer, and dev server — ready to run.
- 2Install dependencies
- 3Add AutoRunnerProjectile
Copies its source into src/ so the scene resolves.
First time? Run bjs login once.
- 4Paste the scene into src/scenes/arcade-room.ts and run
SceneLoader builds the world from the JSON; reload to rebuild.
A gun fires with one call from AutoRunnerProjectile.defs:
It returns null when the pool is not up yet (pools appear a frame after the scene loads), and the gun skips that shot. The spec can also carry vy, a damage for this one round, and a missile's first target.
Hits along the path
A fast round moves further in one frame than a car is wide. Test only where it ends up and it skips clean through. So the test runs along the whole path, fattened by the round's radius:
Cars are tested as their CarCollision boxes. Anything tagged air is tested as a circle.
Missile turns
A missile can only turn so fast:
A helicopter that turns inside that circle makes the missile miss. With no target given, a missile with a seekTag picks the nearest match within 220 m and about 69° either side of its nose.
Blast falloff
A burst hurts everything it may hurt inside explodeRadius, except the target it struck, which already took the full hit. It sends one autoRunnerProjectile.hit per target it catches, then one autoRunnerProjectile.exploded.
The distance counts from roughly the car's near side, not its centre.
Who can be hit
A target needs Health and one of the round's targets tags. It must be on the road for a ground round, or tagged air for an air round. Rounds never hit their owner, a pool blueprint, or a car tagged ghost, and a bomb higher than 2.4 m passes over cars until it comes down. Armour tagged bulletproof sends a round that is not piercing away as a ricochet, with no damage.
Settings
| Field | Default | What it does |
|---|---|---|
kind | "bullet" | bullet, shell, missile or bomb. |
life | 0.9 | Seconds before it is put away. A missile with a burst radius bursts when it runs out. |
damage | 6 | Damage to the target it strikes, and the most a burst does. |
radius | 0.35 | How fat the round is for hit tests, metres. |
targets | ["car"] | Tags it can hurt. |
air | false | Can hit air targets. |
ground | true | Can hit things on the road. |
piercing | false | Goes through bulletproof armour. |
explodeRadius | 0 | Burst radius, metres. 0 is no burst. |
thrust | 60 | Missile: speed gained per second, m/s². |
maxSpeed | 110 | Missile: top speed, m/s. |
turnRate | 2.6 | Missile: fastest turn, rad/s. |
seekTag | "" | Missile: the tag it hunts when it has no target. |
gravity | 14 | Bomb: downward pull, m/s². |
Events
| Event | Payload | Direction |
|---|---|---|
autoRunnerProjectile.launched | { entityId, kind, owner, x, z } | emits |
autoRunnerProjectile.hit | { entityId, targetId, owner, kind, x, z, damage } | emits |
autoRunnerProjectile.ricochet | { entityId, targetId, owner, kind, x, z } | emits |
autoRunnerProjectile.exploded | { entityId, owner, kind, x, z, radius, ground } | emits |
autoRunnerProjectile.ended | { entityId, kind, x, z, reason }, reason is hit, ricochet, ground or expired | emits |
health.damage | { entityId, damage } | emits |
Needs
- MeshPrimitive holds each round's pose, and the size of a target with no CarCollision.
- CarCollision gives each car's box for the hit test, and how much damage the car takes.
- CarDrive gives each car's heading, so its box points the right way.
- Health decides who can be hurt. A target with no hit points left is skipped.









































