logo
Bumper

pinball

Bumper

Talks toScore
1
Unlock

Install with the CLI:

bjs download Bumper

Bumper

A proximity-based scoring trigger: when a ball crosses its hit radius it awards points to a score owner.

What it does

Each bumper entity owns its own hit radius and point value. The system runs an XZ distance check against every ball-tagged entity and, the frame a ball enters hitRadius, emits bumper.hit plus score.add to award points to ownerEntity. A per-bumper-per-ball debounce keeps a slow rolling ball from re-triggering every frame — the flag clears only once the ball moves beyond releaseRadius. The system is renderer-agnostic: it reads MeshPrimitive positions only and never touches Babylon or Havok, leaving the physical deflection to a Physics component on the same entity.

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.

Fastest path

bjs download scene Bumper

Pulls this exact scene into your project and runs it — no copy-paste. Add --all to grab the components and assets it needs too.

Or 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 Bumper
    bjs download Bumper

    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
{
  "ScoreState": {
    "components": {
      "Score": { "defaultPoints": 100, "scores": { "Player": 0 } }
    }
  },
  "Bumper_Center": {
    "components": {
      "MeshPrimitive": {
        "primitive": "cylinder",
        "diameter": 1.78,
        "height": 1.5,
        "position": [0, 0.75, 0],
        "material": { "diffuseColor": [0.95, 0.35, 0.65], "emissiveColor": [0.55, 0.15, 0.35] }
      },
      "Physics": { "shapeType": "capsule", "motionType": "static", "restitution": 0.95, "friction": 0.02 },
      "Bumper": { "points": 500, "hitRadius": 1.25, "releaseRadius": 1.7, "ownerEntity": "Player" }
    }
  }
}

Props

  • points (number, default 100) — points awarded to ownerEntity per hit.
  • hitRadius (number, default 1.4) — XZ distance at which a contact registers.
  • releaseRadius (number, default 1.9) — XZ distance at which the contact flag resets, allowing a new hit.
  • ownerEntity (string, default 'Player') — score recipient, keyed by Score's entity map.

Events

  • emits bumper.hit — when a ball enters hitRadius; payload { bumperId, ballId, points }.
  • emits score.add — alongside the hit, to credit ownerEntity with points.

Dependencies

MeshPrimitive — supplies the bumper and ball positions for the distance check. Score — receives the score.add event and tracks the owner's total.

Notes

  • Set releaseRadius larger than hitRadius so a ball lingering at the edge can't chatter on/off.
  • The bounce itself is not done here — add a Physics body (e.g. static with high restitution) on the same entity for the actual deflection.
  • The in-contact debounce state is runtime-only, kept off the serializable Component.

More like this

MeshPrimitive
Score
BoatMode
BoatWater
ContactDamage
ContactImpulse
Flipper
MouseHole
Obstacle
Physics
PinballBuilder
PinballBuilderInput
PinballCamera
PinballLayout
PinballTable
Plunger
Spinner
SurfacePatch
Velocity6DOF

Was this page helpful?

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

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search