UGTK / Toolkit / Gameplay Systems / Checkpoint System Completed
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
- UGTK.DesignPattern.Singleton —
Mn_CheckpointManagerderives fromMn_Singleton<T>.
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
- Give every checkpoint an
Mn_Checkpointwith a uniquecheckPointId. Optionally set aspawnPivot, alocalSpawnOffset, and enableuseCheckpointRotation. - Register a checkpoint by calling
SetAsLastCheckPoint()from a player trigger or UnityEvent (same method name as Arcadevania prefabs). It stores the id on the manager and fires thepassedAnimatorTrigger(default"Passed"). - Respawn a target with
Mn_CheckpointManager.Instance.TeleportToLastCheckpoint(target)(acceptsGameObjectorTransform), or teleport to a specific id viaTeleportToCheckpoint(id, target). - Teleport handles
Rigidbody,Rigidbody2D, or plain transforms; velocities are zeroed whenzeroRigidbodyVelocitiesis enabled and rotation is applied only when both the manager and checkpoint allow it. - Enable
teleportOnStartwith anautoTeleportTargetto place the player at the saved checkpoint on scene start. ClearSavedCheckpointData()resets the persisted data and fires each checkpoint'sresetAnimatorTrigger(default"Reset").
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:
- Enter Play mode and select CheckpointDemo.
- 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.
- Run 1 - Reach next checkpoint again for the second flag.
- Run 2 - Fall into the pit. The cube goes back to the starting corner, the way a death would send it.
- Run 3 - Respawn at last checkpoint. The cube lands on the second flag, not the first.
- 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.assetand 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
- Mn_CheckpointManager: singleton; caches scene checkpoints (
RefreshCheckpointsFromScene), stores the last checkpoint on theSO_LastCheckpointData, and teleports targets (2D/3D) with optional rotation and velocity reset. - Mn_Checkpoint: per-checkpoint marker exposing
CheckPointId, world spawn pose helpers,SetAsLastCheckPoint(), and passed/reset animator triggers. - SO_LastCheckpointData: ScriptableObject storing the last-activated id and the list of ids reached at least once (
HasCheckpoint,AddPassedCheckpoint,Clear). - Mn_CheckpointDemo (
Debug/): drives the test scene from the Inspector - walks the player to the next checkpoint, drops it into the pit, respawns it, clears the progress. Not part of the runtime module.
Teleporting writes the pose, it does not sweep to it.
ApplyTeleportassignsRigidbody.positionand the Transform in the same call, rather thanMovePosition: 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
PlayPassedAnimationandPlayResetAnimationcallResetTriggeron the opposite one first.
© 2026 Marcello De Bonis. All rights reserved
Used by 1
Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 4 modules in total.
UGTKengine within an engine


