logo

Babylon.js Market

RespawnTimer

gameplay

RespawnTimer

1
Unlock

Install with the CLI:

bjs download RespawnTimer

RespawnTimer

The death-pause countdown a 6-DOF dogfighter clips onto the player when its ship is blown apart — hold the ship dead for a couple of seconds, then respawn it at the spawn point.

What it does

RespawnTimerComponent is pure data: one field, remaining, the seconds left in the death pause. When the player ship is destroyed, the shared destroyShip kill path attaches a RespawnTimer to it and freezes the ship dead. The shared death/respawn path counts remaining down each frame; when it reaches zero, a respawn system teleports and rebuilds the ship at the spawn point. There's no RespawnTimerSystemmeta.json lists none — so the decrement and the respawn trigger live in that shared path, driven off the component's presence on the player entity rather than a per-frame System of its own. It's the one-shot player-respawn cousin of Lifetime: same countdown shape, but for a single revive pause instead of pooled recycling. serialize() round-trips the single number, so the death pause survives a save/reload mid-countdown.

Use it in a scene

Normally the kill path attaches this at runtime, not the scene author. Pre-attaching one starts the ship in its death pause on load:

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

    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": {
      "RespawnTimer": { "remaining": 2 }
    }
  }
}

Props

  • remaining (number, default 2) — seconds left in the death pause. The shared respawn path decrements it each frame and rebuilds the ship at spawn once it hits zero. Raise it for a longer dead-time before the player flies again.

Events

  • Emits nothing. meta.json declares an empty emits, and the component holds no events constant.
  • Listens for nothing. The countdown isn't bus-driven — the shared death/respawn path reads the component off the player entity directly.

Dependencies

  • None declared. meta.json lists an empty dependencies array; RespawnTimer is standalone pure data. Its behavior belongs to the shared destroyShip/respawn path that attaches and consumes it — the component itself imports only @babylonjsmarket/ecs and pulls in no other component.

Notes

  • Transient by design. A RespawnTimer only exists between death and respawn, so it's rarely authored into a scene. The debug panels (RespawnTimer.viz.tsx / RespawnTimer.panel.tsx) reflect this — they canBuild only once a RespawnTimer is live in the world, and the remaining slider writes through to every timer at once.
  • The countdown lives elsewhere. Nothing on the component decrements remaining; that's the shared respawn path's job. A scene that attaches a RespawnTimer without that path wired up will sit at its initial remaining forever.

More like this

AiPilot
Animation
ArcCamera
Asteroid
BallPossession
BallReset
Bullet
CameraFollow
DirectionalLight
Enemy
EnemySpawner
EnvironmentTexture
FreighterCar
FreighterChain
FreighterHead
GameConfig
Goal
Health
HemisphericLight
Jump
KeyboardInput
KeyboardMover
Lifetime
LineOfSight
MachineGun
Mesh
MeshPrimitive
Missile
MissileLauncher
MissionDirector
Movement
Obstacle
ObstacleField
OilBlob
Parts
Physics
PlayerInput
PlayerWalkAnimator
Score
Scoreboard
Shadow
ShipLoadout
SkeletonAnimator
SoccerDirector
SpaceShooterBullet
SpaceShooterHealth
SpaceShooterScore
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