UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Gameplay Systems / Checkpoint System Completed

Gameplay Systems — UGTK

Checkpoint System

Summary

Tracks scene checkpoints and teleports a target (2D or 3D) to the last saved checkpoint pose, persisting the last-reached id in a ScriptableObject.


Content


Modules Dependencies

Carried inside the prefabs. These modules are not referenced by the assembly definition - the components are simply already attached to the prefabs this module ships. Remove one of them from the project and the prefab keeps its layout and loses that behaviour, with nothing in the console to say so.

Module Component, and the prefab carrying it
ComponentModule/ColliderAutoResizeComponent Mn_ColliderAutoResizeComponent (in CheckPointFlag_2D)
UtilitySystems/CollisionSystem Mn_Collider2DEvents (in CheckPointFlag_2D), Mn_Collider3DEvents (in CheckPointFlag_3D)

Setup

Create a SO_LastCheckpointData asset (UGTK/Gameplay Systems/Checkpoint System/Last Checkpoint Data), add one Mn_CheckpointManager to the scene and assign that asset, then place Mn_Checkpoint components on your checkpoint objects with a unique id each.


How To Use


Testing Scene

Open Debug/CheckpointScene.unity. Four CheckPointFlag_3D prefabs stand on a ground plane, an orange cube plays the part of the player, and CheckpointDemo carries Mn_CheckpointDemo: the whole run is driven from that component's context menu, so no player controller is needed.

What to do, in order:

  1. Enter Play mode and select CheckpointDemo.
  2. Right-click the component header and run 1 - Reach next checkpoint. The cube walks onto the first flag and the flag turns blue: the checkpoint is now the saved one.
  3. Run 1 - Reach next checkpoint again for the second flag.
  4. Run 2 - Fall into the pit. The cube goes back to the starting corner, the way a death would send it.
  5. Run 3 - Respawn at last checkpoint. The cube lands on the second flag, not the first.
  6. Run 4 - Clear progress. Every flag goes back to white and the saved asset is emptied.

Step 5 is the one that catches the classic defect: a checkpoint that re-arms when you pass it in the wrong direction sends the player backwards on the next death, which reads as the game losing their progress. Step 6 is the second one: the flags have to go back to their unreached look, otherwise a new run starts with the old run's flags still lit.

The saved id lives in Debug/SO_LastCheckpoint_Debug.asset and survives leaving Play mode, so a run that ends half way starts again half way. 4 - Clear progress is what puts it back to zero.


Technical Info

Teleporting writes the pose, it does not sweep to it. ApplyTeleport assigns Rigidbody.position and the Transform in the same call, rather than MovePosition: a respawn has to land on the frame it was asked for, and a swept move drags the player through everything in between. Velocities are only cleared on non-kinematic bodies, because writing a velocity on a kinematic one is an error in Unity.

The passed / reset animator triggers clear each other. A trigger nobody consumes stays armed, so a checkpoint that was reset while idle would flip back on its own the next time it was reached. Both PlayPassedAnimation and PlayResetAnimation call ResetTrigger on the opposite one first.


© 2026 Marcello De Bonis. All rights reserved

Real dependenciesOpen in the map →

Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 4 modules in total.