Checkpoints
Implement respawn checkpoints and progression tracking.
Introduction
Checkpoints let players retry difficult sections without restarting. This guide covers checkpoint placement, activation, respawn logic, and cloud persistence.
Guide 14 of 25
Screenshot
Step-by-Step Guide
Create checkpoint objects
Place checkpoint triggers at key locations. Use invisible trigger volumes or visible flags.
Track active checkpoint
Store the current checkpoint ID. When a new one triggers, update the active and deactivate previous.
Implement respawn
On player death, wait 2-3 seconds, then respawn at the active checkpoint with full health.
Add visual feedback
When activated, show flag-raising animation, particle effect, UI notification, and play a sound.
Persist to cloud
Save the active checkpoint so players resume from their last checkpoint after closing the game.
Handle level restart
If the player restarts manually, reset to the first checkpoint or the cloud-saved one.
FluxScript Example
Here is a complete FluxScript implementation for this guide:
activeCheckpoint = null
on start {
checkpoints = world.findAll("checkpoint")
for i = 0 to checkpoints.length {
checkpoints[i].activated = false
checkpoints[i].setMaterial("flag_red")
}
saved = save.get("activeCheckpoint")
if saved != null {
for i = 0 to checkpoints.length {
if checkpoints[i].id == saved activateCheckpoint(checkpoints[i])
}
}
}
func activateCheckpoint(cp) {
if activeCheckpoint != null {
activeCheckpoint.setMaterial("flag_red")
activeCheckpoint.activated = false
}
activeCheckpoint = cp
cp.activated = true
cp.setMaterial("flag_green")
cp.playAnimation("raise")
effects.spawn("checkpoint_effect", cp.position)
audio.play("checkpoint")
ui.toast("Checkpoint reached!")
save.set("activeCheckpoint", cp.id)
save.flush()
}
on triggerEnter(other) {
if other.type == "player" && !self.activated {
activateCheckpoint(self)
}
}
on event("playerDied") {
ui.show("deathScreen")
timer.start("respawn", 3.0, 1)
}
on timer("respawn") {
player = scene.find("Player")
if activeCheckpoint != null {
player.setPosition(activeCheckpoint.position + vec3(0, 1, 0))
player.setHealth(player.maxHealth)
player.setVelocity(vec3(0, 0, 0))
} else {
scene.reload()
}
ui.hide("deathScreen")
gameRunning = true
}Node Graph Example
Prefer visual programming? Here is the equivalent Node Graph:
[On Start] --> [Find All: checkpoints] --> [Set: red flags]
--> [Load: saved checkpoint] --> [Activate if found]
[On Trigger Enter] --> [Branch: player + !activated]
--> [Activate: green flag, animation, effect, sound]
--> [Save to Cloud]
[On Event "playerDied"] --> [Show: deathScreen] --> [Timer: respawn 3s]
[On Timer "respawn"] --> [Branch: activeCheckpoint]
+-- True --> [Set Position + Health + Velocity]
+-- False --> [Scene Reload]Optimization Tips
Keep your implementation fast and efficient with these optimization tips:
- Save checkpoints to cloud storage. Players expect to resume from their last checkpoint after closing the game.
- Validate checkpoint position before respawning. If the area has changed, adjust the respawn position.
- Give players 2-3s invulnerability after respawning. Prevents instant re-death from nearby enemies.
- Use trigger volumes for checkpoints, not collision. Triggers detect without blocking movement.
Common Mistakes
Checkpoint too close to a hazard
Place checkpoints in safe areas. Respawning next to the hazard is frustrating.
No visual feedback on activation
Players need to know a checkpoint activated. Show visual change and play a sound.
