logo

Babylon.js Market

Obstacle

shooter

Obstacle

Free

Install with the CLI:

bjs download Obstacle

Obstacle

A static, axis-aligned box barrier that carries collision semantics for movement, bullets, and line of sight.

What it does

Obstacle marks an entity as a solid box on the play field — movement is always blocked, while blocksBullets and blocksSight distinguish full-height walls from low cover. It has no per-frame System of its own: it's static collision data plus pure helper math (resolveCircleVsBox, segmentIntersectsBox) and a collectObstacleBoxes(world) query. Gameplay systems (movement, bullets, line of sight) call that query each frame to snapshot live obstacle footprints and resolve collisions themselves. The XZ footprint is derived from halfWidth/halfDepth centered on the sibling MeshPrimitive's position.

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 Obstacle

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

    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
{
  "Wall": {
    "components": {
      "MeshPrimitive": {
        "primitive": "box",
        "width": 4,
        "height": 2,
        "depth": 1,
        "position": [0, 1, 0],
        "material": { "diffuseColor": [0.35, 0.18, 0.45] }
      },
      "Obstacle": { "halfWidth": 2, "halfDepth": 0.5, "blocksSight": true, "blocksBullets": true }
    }
  }
}

Props

  • halfWidth (number, default 1) — half-extent of the box footprint along X.
  • halfDepth (number, default 1) — half-extent of the box footprint along Z.
  • blocksSight (boolean, default true) — true for a full-height wall that breaks line of sight; false for low cover that doesn't.
  • blocksBullets (boolean, default true) — true for a full-height wall that stops bullets; false for low cover that lets them through.

Dependencies

MeshPrimitive — supplies the box's world position; collectObstacleBoxes reads it together with halfWidth/halfDepth to build each obstacle's XZ footprint.

Notes

  • Movement is always blocked regardless of flags; only bullets and sight are configurable via blocksBullets / blocksSight.
  • halfWidth/halfDepth should match the sibling MeshPrimitive box (width/depth ÷ 2) so the collision footprint lines up with the rendered mesh.
  • collectObstacleBoxes is cheap and meant to be rebuilt each frame by consumers rather than cached; it skips inactive entities and any obstacle missing a MeshPrimitive.

More like this

MeshPrimitive
AiPilot
Animation
ArcCamera
Asteroid
Bullet
Bumper
CameraFollow
DirectionalLight
Enemy
EnemySpawner
EnvironmentTexture
FreighterCar
FreighterChain
FreighterHead
GameConfig
Health
HemisphericLight
Jump
KeyboardInput
KeyboardMover
Lifetime
LineOfSight
MachineGun
Mesh
Missile
MissileLauncher
MissionDirector
MoneyField
MouseHole
Movement
ObstacleField
OilBlob
Parts
Physics
PlayerInput
PlayerWalkAnimator
RespawnTimer
Score
Shadow
ShipLoadout
ShooterCamera
SkeletonAnimator
SpaceShooterBullet
SpaceShooterHealth
SpaceShooterScore
Spinner
TwinStickShooter
Velocity6DOF
WaveDirector
Waypoint
WaypointTrack

Was this page helpful?

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

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search