logo

Babylon.js Market

WaypointTrack

shooter · space-combat-sim

WaypointTrack

1
Unlock

Install with the CLI:

bjs download WaypointTrack

WaypointTrack

The player's progress marker through a Waypoint gate run — which gate they're on, how many there are, and whether the track is done.

What it does

WaypointTrackComponent is pure data that rides on the player entity: currentIndex (the gate currently being steered toward), totalCount (how many gates the track has — auto-initialised from the live gate count when it's 0), and completed. It has no System of its own. The Waypoint component's WaypointSystem reads this marker off the player each frame, advances currentIndex as the player clears each gate, flips completed past the final gate, and repaints the gate meshes accordingly.

It's a separate scene key (rather than a field of a gate) because there is exactly one tracker and it belongs on the player, while the gates are many and belong wherever the level authors them.

Use it in a scene

Put WaypointTrack on the player, and Waypoint gates in the world:

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

    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": {
    "tags": ["player"],
    "components": {
      "Transform6DOF": { "x": 0, "y": 0, "z": 0 },
      "WaypointTrack": { "currentIndex": 0 }
    }
  },
  "Gate0": {
    "components": {
      "Transform6DOF": { "x": 0, "y": 0, "z": 200 },
      "Waypoint": { "index": 0, "radius": 25 },
      "Renderable": { "shape": "gate" }
    }
  }
}

totalCount left at 0 auto-fills from the number of Waypoint entities the first frame the system runs.

Props

  • currentIndex (number, default 0) — the gate the player is steering toward. Advanced by WaypointSystem as gates are cleared.
  • totalCount (number, default 0) — total gates in the track. Left at 0, it auto-initialises from the live gate count.
  • completed (boolean, default false) — set true once the final gate is reached.

Dependencies

  • Waypoint — defines the WaypointTrackComponent class and the WaypointSystem that reads and advances it, plus the gate entities it tracks against. WaypointTrack is inert without at least one Waypoint gate and the system that comes with it.

Notes

  • This component is data-only. All the motion — advancing the index, latching reached/missed, emitting wingman.waypoint.reached / wingman.track.completed, repainting gates — lives in WaypointSystem, which ships with Waypoint. Downloading WaypointTrack pulls Waypoint along as a dependency so the system is present.
  • One tracker per run. WaypointSystem reads the first entity that has a WaypointTrackComponent; put it on the player and nowhere else.

More like this

Waypoint
AiPilot
Animation
ArcCamera
Asteroid
Bullet
CameraFollow
ChaseCamera6DOF
ChaseCameraTarget
DirectionalLight
Enemy
EnemySpawner
EnvironmentTexture
FlightIntent
FreighterCar
FreighterChain
FreighterHead
GameConfig
Health
HemisphericLight
Jump
KeyboardInput
KeyboardMover
Lifetime
LineOfSight
MachineGun
Mesh
MeshPrimitive
Missile
MissileLauncher
MissionDirector
MoneyField
Movement
Obstacle
ObstacleField
OilBlob
Parts
Physics
PlayerFlightInput
PlayerInput
PlayerWalkAnimator
RespawnTimer
Score
Shadow
ShipFlight
ShipLoadout
ShooterCamera
SkeletonAnimator
SpaceDust
SpaceShooterBullet
SpaceShooterHealth
SpaceShooterScore
TwinStickShooter
WaveDirector
WorldOriginAnchor

Was this page helpful?

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

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search