CheckpointSystem class
Checkpoint / respawn system.
Scans entities that have a CheckpointComponent and, every frame, checks whether any player entity (identified by playerTag) is within the checkpoint's CheckpointComponent.radius. When a player enters an unactivated checkpoint for the first time, the checkpoint is marked as activated and a CheckpointActivatedEvent is fired.
The system also exposes respawn and setRespawnPoint helpers that game code can call directly.
Setup:
world.addSystem(CheckpointSystem(playerTag: 'player'));
Respawn on death:
world.events.on<PlayerRespawnEvent>((e) {
final transform = e.playerEntity.getComponent<TransformComponent>()!;
final velocity = e.playerEntity.getComponent<VelocityComponent>()!;
transform.position.setFrom(e.respawnPosition);
velocity.setVelocityXY(0, 0);
});
Constructors
- CheckpointSystem({String playerTag = 'player'})
-
Creates a CheckpointSystem that looks for player entities tagged with
playerTag.
Properties
- currentRespawnPoint → Vector3
-
no setter
-
entities
→ Iterable<
Entity> -
Get all entities that match this system's requirements
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isActive ↔ bool
-
Whether this system is active
getter/setter pairinherited
- playerTag → String
-
Tag string used to identify player entities.
final
- priority ↔ int
-
Priority for system execution order (higher = earlier)
getter/setter pairinherited-setteroverride-getter
-
requiredComponents
→ List<
Type> -
Required component types for this system
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- world ↔ World
-
World this system belongs to
getter/setter pairinherited
Methods
-
dispose(
) → void -
Dispose system resources
inherited
-
forEach(
void action(Entity entity)) → void -
Execute a function for each matching entity
inherited
-
initialize(
) → void -
Initialize the system
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onAddedToWorld(
) → void -
Called when system is added to world
inherited
-
onRemovedFromWorld(
) → void -
Called when system is removed from world
inherited
-
render(
Canvas canvas, Size size) → void -
Render the system (optional)
override
-
respawn(
Entity playerEntity) → void -
Immediately teleport
playerEntityto_currentRespawnPointand fires a PlayerRespawnEvent. Call this when the player dies. -
setRespawnPoint(
Vector3 position) → void - Manually set the active respawn point without requiring the player to touch a checkpoint entity. Useful for level-start defaults.
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
double deltaTime) → void -
Update the system
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited