logo
AutoRunnerBomber

vehicle · vehicle-combat

AutoRunnerBomber

1
Unlock

Install with the CLI:

bjs download AutoRunnerBomber

AutoRunnerBomber

The bomber: a helicopter that sits ahead of you and drops bombs where you are about to be.

What it does

autoRunnerBomber.dispatch takes the bomber from its pool and brings it in 70 m behind the player, a little above its flying height. It settles onto a station ahead metres in front of the car, weaves across the road, and drops a bomb every bombEvery seconds or so. Each bomb is aimed at where the car will be when it lands. Brake or swerve and it misses.

When its stay time is up or its bombs run out, the bomber climbs, pulls away up the road and goes back to its pool. With the defaults it usually runs out of bombs first: a full load lasts about 18 seconds.

Give its blueprint the air tag and a Health. Only rounds that reach the air, which means missiles, can hurt it. When health.died arrives for it, the bomber is removed on the next frame.

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:

  1. 1Scaffold a project
    npm create @babylonjsmarket/arcade@latest my-game

    World, renderer, and dev server — ready to run.

  2. 2Install dependencies
    cd my-game && npm install
  3. 3Add AutoRunnerBomber
    bjs download AutoRunnerBomber

    Copies its source into src/ so the scene resolves.

    First time? Run bjs login once.

  4. 4Paste the scene into src/scenes/arcade-room.ts and run
    npm run dev

    SceneLoader builds the world from the JSON; reload to rebuild.

JSON
{
  "BomberBlueprint": {
    "tags": ["helicopter", "air", "enemy"],
    "components": {
      "Pool": { "name": "helicopter", "size": 2 },
      "MeshPrimitive": {
        "primitive": "box",
        "width": 2,
        "height": 1.7,
        "depth": 9
      },
      "Shadow": { "castShadow": true },
      "Health": { "hp": 110 },
      "AutoRunnerBomber": { "target": "Player", "bombPool": "bomb" }
    }
  },
  "BombBlueprint": {
    "tags": ["round"],
    "components": {
      "Pool": { "name": "bomb", "size": 12 },
      "MeshPrimitive": {
        "primitive": "sphere",
        "diameter": 0.7,
        "segments": 8
      },
      "AutoRunnerProjectile": {
        "kind": "bomb",
        "life": 6,
        "damage": 45,
        "radius": 0.5,
        "targets": ["car"],
        "air": false,
        "ground": true,
        "piercing": true,
        "explodeRadius": 5.5,
        "gravity": 16
      }
    }
  }
}

The bomber works out its aim with a gravity of 16 and sends that gravity with every bomb it drops, so the bomb blueprint's own gravity never throws the aim off.

Leading the target

Two numbers decide where a bomb lands: how long it falls, and how far the car goes in that time.

TypeScript
export function fallTime(height: number, g: number): number {
  return Math.sqrt((2 * Math.max(0.1, height)) / Math.max(0.1, g));
}
TypeScript
  const ax = tx + tvx * t, az = tz + tvz * t;
  let vx = (ax - x) / t, vz = (az - z) / t;

(ax, az) is where the car will be after t seconds at its current speed. The bomb is thrown at whatever speed carries it there in the same t, capped at 70 m/s. A worked drop with the defaults and a car doing 40 m/s:

text
drop height:  15 m, less 1.2 m (it starts below the body) = 13.8 m
fall time:    √(2 × 13.8 / 16)                            = 1.31 s
car travels:  40 m/s × 1.31 s                             = 52.5 m
throw:        52.5 m − the bomber's 34 m lead             = 18.5 m forward

The bomb comes down where the car would have been. A player who brakes is short of it; one who changes lanes is beside it.

The station

TypeScript
export function station(t: number, ahead: number, sway: number, halfWidth: number, seed: number): { ds: number; u: number } {
  return {
    ds: ahead + Math.sin(t * 0.55 + seed) * 6,
    u: Math.sin(t * 0.8 + seed * 2) * Math.min(sway, halfWidth + 2),
  };
}

ds is distance up the road from the car and u is distance across it. Both are measured along the road, so the station follows the bends. Around ahead, the bomber drifts 6 m forward and back, and it weaves sway metres either side, but never more than 2 m past the road's edge. A random seed per flight keeps two bombers from flying in step.

Model and shadow

The body is the entity's own MeshPrimitive, reshaped once into a helicopter about 8 m nose to tail and painted bodyColor. Its Shadow then throws a helicopter-shaped shadow on the road. The rotor and a blinking red beacon are separate meshes the System owns. The rotor spins at rotorSpeed and casts a flickering shadow from the first sun announced on directionallight.created.

Settings

FieldDefaultWhat it does
pool"helicopter"Pool that autoRunnerBomber.dispatch draws from. Every bomber blueprint should name the same one.
target"Player"The car it hunts
altitude15Flying height, metres
ahead34How far ahead of the target it holds station, metres
sway8How far it weaves across the road, metres
bombEvery1.5Seconds between bombs, give or take 25%
bombs12Bombs it carries
bombPool"bomb"Pool the bombs come from
stay26Seconds it stays before leaving
rotorSpeed24Rotor spin, rad/s
agility1.6How quickly it closes on its station, per second. It uses 1.8 times this while it flies in.
bodyColor[0.16, 0.17, 0.18]Body colour, RGB from 0 to 1

Events

EventPayloadDirection
autoRunnerBomber.arrived{ entityId }emits
autoRunnerBomber.bomb.dropped{ entityId, x, z }emits
autoRunnerBomber.left{ entityId }emits, when it turns to leave
autoRunnerBomber.dispatch{}listens
health.died{ entityId }listens: a shot-down bomber is removed
directionallight.created{ entityId, handle, direction, position, intensity }listens: the rotor's shadow comes from this light

Needs

  • MeshPrimitive is the body.
  • CarDrive gives the target's heading and speed, for the lead.
  • HighwayRoad gives road distance and width, so the station follows the road.
  • AutoRunnerProjectile supplies the bombs through launchProjectile.
  • Shadow casts the body's shadow.
  • Health lets missiles shoot it down.

More like this

AutoRunnerDirector
AutoRunnerProjectile
CarDrive
DirectionalLight
Health
HighwayRoad
MeshPrimitive
RoadAudio
Shadow
AIGoalSeek
AIKick
AIZone
AiDriver
AiPilot
Asteroid
AutoRunnerDriver
AutoRunnerHUD
AutoRunnerWeapons
BallPossession
BallPursuit
BoatMode
BoatWater
Bullet
CarCollision
CarPaint
ContactDamage
ContactImpulse
DayNightCycle
Enemy
EnemySpawner
FreighterChain
Headlights
HighwaySpawner
LineOfSight
MachineGun
Missile
MissileLauncher
OilBlob
Parts
PokerAI
PokerAIBill
PokerAICali
PokerAIRandy
PokerAIShark
PokerAISurge
PokerAITilt
RoadCamera
RoadFX
RoadHazard
RoadSpawner
RoadTreadmill
RoadsideScenery
ShipLoadout
SmokeScreen
SupplyTruck
SurfacePatch
TrafficConvoy
TwinStickEnemy
WaveDirector
WeaponsVan

Was this page helpful?

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

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search