Adding A Respawn Checkpoint
Revisado con versión: 2018.1
Checkpoints are a common element of most modern games and the Gamekit provides a prefab that can be found in 3D Gamekit > Prefabs > Utilities > Checkpoint.
When Ellen dies, she will be respawned at the last checkpoint she touched. To ensure that the player gets an update as to where they are going to respawn you should use an object or visual cue in the game to illustrate the player hit the checkpoint.
In this example we are going to add another Crystal to the scene, this time being activated by a Checkpoint enter event by sending a Game Command to it.
- To add a checkpoint you can simply drag and drop it into the scene and place it to ensure that the player can enter the collider. Resize to ensure it is not too large an area.
- Set the Layer setting to Checkpoint in the Inspector.
Add a Crystal from 3D Gamekit > Prefabs > Interactables
Place it near the checkpoint area
To make it more obvious what this Crystal is being used for in the Hierarchy, rename it in the Inspector to CheckpointCrystal
To link the two objects select the Checkpoint
Click Add Component
Type Send On Trigger Event
Confirm the addition by hitting enter or clicking on the result
Set Interaction Type to Activate
Set One Shot to Enabled
Set Layers to Player. This will allow Ellen to collide with the area
Set Interactive Object to GateCheckpoint via the GameObject selection
- To verify the connection between them, select the CheckpointCrystal and in the Inspector verify that the Game Command Receiver has a Sender attached.
Play the game at this stage and walk into the Checkpoint to see the Crystal now activate on entry. After activation, killing Ellen will result in her respawning in the center of the Checkpoint volume.