logo
AutoRunnerWeapons

vehicle · vehicle-combat

AutoRunnerWeapons

1
Unlock

Install with the CLI:

bjs download AutoRunnerWeapons

AutoRunnerWeapons

The player car's guns, missiles, oil and smoke.

What it does

Hold Space and the machine guns fire. Press E for one missile, with a short cooldown between them. Hold Q and an oil slick lands behind the car every dropEvery seconds; R does the same with smoke.

Guns never run out. Missiles, oil and smoke do, and come back from the weapons truck through autoRunnerWeapons.grant. A key pressed for an empty weapon sends autoRunnerWeapons.empty, so a HUD can flash it.

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 AutoRunnerWeapons
    bjs download AutoRunnerWeapons

    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
{
  "Player": {
    "components": {
      "AutoRunnerWeapons": {
        "gunLevel": 1,
        "missiles": 2,
        "oil": 4,
        "smoke": 4
      }
    }
  }
}

Put it on a car with CarDrive and MeshPrimitive. The scene needs pools named bullet, missile, oil and smoke, or set the pool names. It is the missile blueprint's own seekTag that makes it hunt the bomber; this part only fires it.

Gun levels

TypeScript
export function gunMuzzles(level: number, side: number, forward: number): Muzzle[] {
  if (level <= 1) return [{ side: 0, forward, angle: 0 }];
  if (level === 2) {
    return [
      { side: -side, forward, angle: 0 },
      { side, forward, angle: 0 },
    ];
  }
  return [
    { side: -side, forward, angle: -0.035 },
    { side, forward, angle: 0.035 },
    { side: 0, forward: forward + 0.2, angle: 0 },
  ];
}

/** Rounds per second for a gun level. */
export function gunRate(level: number, base: number): number {
  return base * (level >= 3 ? 1.5 : level === 2 ? 1.2 : 1);
}

Each trigger pull fires every muzzle at once, so a level's punch is barrels times rate times damage. With the default gunRate and bulletDamage:

text
level 1: 1 barrel  ×  9.0 pulls/s × 7 =  63 damage/s
level 2: 2 barrels × 10.8 pulls/s × 7 = 151 damage/s
level 3: 3 barrels × 13.5 pulls/s × 7 = 284 damage/s

At level 1 the System swaps its one barrel left and right each shot, so it sounds like a twin mount. At level 3 the outer two barrels fan out by about 2 degrees.

Rounds keep the car's speed

Every round starts with the car's own speed added to its launch speed:

TypeScript
        vx: vx + p.dirX * w.missileSpeed,
        vz: vz + p.dirZ * w.missileSpeed,

This matters most for the slow rounds. A missile fired at the default 45 m/s from a car doing 52 m/s would start out slower than the car that fired it. With the car's speed added, it leaves at 97 m/s and pulls ahead. Oil and smoke do not move: each one lands dropBack metres behind the car, facing the way the car faces.

Settings

FieldDefaultWhat it does
gunLevel1Starting gun level
missiles0Starting missiles
oil0Starting oil slicks
smoke0Starting smoke clouds
maxGunLevel3Highest gun level a grant can reach
maxMissiles6Most missiles the car can hold
maxOil10Most slicks the car can hold
maxSmoke10Most clouds the car can hold
gunRate9Trigger pulls per second at level 1
bulletSpeed150Round speed, m/s, on top of the car's
bulletDamage7Damage per round
muzzleForward2.4How far ahead of the car's centre the guns sit, metres
muzzleSide0.55How far out to each side the barrels sit, metres
missileSpeed45Missile launch speed, m/s, on top of the car's. It speeds up from there.
missileDamage120Damage per missile
missileCooldown0.6Seconds between missiles
dropEvery0.28Seconds between slicks or clouds while the key is held
dropBack3.2How far behind the car oil and smoke land, metres
bulletPool"bullet"Pool the rounds come from
missilePool"missile"Pool the missiles come from
oilPool"oil"Pool the slicks come from
smokePool"smoke"Pool the clouds come from
fireKeys["Space", "KeyJ"]Keys that fire the guns (KeyboardEvent.code)
missileKeys["KeyE", "KeyK"]Keys that fire a missile
oilKeys["KeyQ", "KeyL"]Keys that drop oil. Oil wins if oil and smoke are both held.
smokeKeys["KeyR", "KeyI"]Keys that drop smoke

Events

EventPayloadDirection
autoRunnerWeapons.fired{ entityId, weapon, x, z }, plus seek: "air" for a missileemits
autoRunnerWeapons.changed{ entityId, gunLevel, missiles, oil, smoke, maxGunLevel, maxMissiles, maxOil, maxSmoke }emits, when the loadout moves
autoRunnerWeapons.empty{ entityId, weapon }emits
autoRunnerWeapons.grant{ entityId, weapon, amount }, weapon is missiles, oil, smoke or gunslistens
autoRunnerWeapons.enabled.set{ entityId, enabled }listens: holds fire while dead, docked or paused
autoRunnerWeapons.reset{ entityId }listens: back to the starting loadout
keyboard.keydown{ code }listens
keyboard.keyup{ code }listens

A grant is capped at the max, so a full tank takes nothing. For guns, amount is levels.

Needs

  • CarDrive supplies heading and speed.
  • MeshPrimitive supplies position.
  • AutoRunnerProjectile supplies the bullet and missile pools through launchProjectile.
  • RoadHazard supplies the oil and smoke pools through dropHazard.
  • KeyboardInput turns DOM keys into keyboard.keydown and keyboard.keyup on the bus, which is how the trigger keys arrive.

More like this

AutoRunnerDirector
AutoRunnerHUD
AutoRunnerProjectile
CarDrive
KeyboardInput
MeshPrimitive
RoadAudio
RoadHazard
SupplyTruck
AiDriver
AiPilot
Asteroid
AutoRunnerBomber
AutoRunnerDriver
BilliardCue
BoatMode
BoatWater
Bullet
CarCollision
CarPaint
ContactDamage
ContactImpulse
DayNightCycle
FlightIntent
Flipper
Headlights
Health
HighwayRoad
HighwaySpawner
Jump
KeyboardMover
MachineGun
Missile
MissileLauncher
MouseInput
OilBlob
Parts
PinballBuilderInput
PlayerFlightInput
PlayerInput
PlayerInputBridge
Plunger
PointerDrag
PokerInput
RoadCamera
RoadFX
RoadSpawner
RoadTreadmill
RoadsideScenery
Rollover
ShipLoadout
SmokeScreen
SurfacePatch
TrafficConvoy
TwinStickEnemy
WeaponsVan

Was this page helpful?

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

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search