Reach a Checkpoint
Part of the Building Real Games section of Coddy's Unity journey. Lesson 53 of 60.
Challenge
MediumMake the red poles move the respawn point.
- In
Checkpoint, writeOnTriggerEnter: when the object has aPlayer, call itsSetCheckpoint(transform.position). - Then turn the pole
Color.greenand logCheckpoint reached. - Keep a
bool reachedso this happens only the first time.
Press Play, touch a pole and fall: you come back at the pole. Then Check.
Try it yourself
using UnityEngine;
public class Checkpoint : MonoBehaviour
{
// A later lesson fills this in: a flag that moves where you come back after a fall.
}
All lessons in Building Real Games
10Project: 3D Platformer
The CourseMoving Platforms2Buttons and Screens
Buttons and onClickLambdasWiring in the InspectorPanels On and OffHealth BarsRecap: Upgrade Shop5Saving with PlayerPrefs
Save a NumberLoad with a DefaultHigh ScoreSave SettingsRecap: Coins in the Bank3The Game Manager
One Script Runs the GameThe SingletonGame StatesSwitching on the StateRecap: Round Manager6Project: Endless Runner
Three LanesObstacles Ahead9The New Input System
Two Input SystemsKeyboard and MousePressed This FrameInput ActionsRecap: Input SwapPractice on your own: Unity playground