Help Needed UE5 Dying Respawn system

Hi there, I am currently learning Unreal Engine 5 with courses online and I start building a game with the skill that I have learned from youtube. However, I face some difficulties building a Re-spawn system when my character dies. I currently have a Game Over menu set up; however, the on-click function for Retry does not work as I intended. I have set up checkpoints in the level and I want the player to spawn at the checkpoint if he or she has collided with the collision box at the checkpoint. But the only way I can think of to implement the on-click function is to reopen the level, how can I use a blueprint and allow my player to respawn at the latest checkpoint location, if no such checkpoint has been achieved the player should respawn at the “Player Start” (Below are my blueprints of BP_ThirdPersoncharacter, GameMode, collision Box, and the dyingMenu)




Can you destroy the player onclick? Looking at your pictures, that should trigger the respawn code?

Make a transform variable and copy the location where that check point is. IF your player can respawn at the check point. Spawn actor of class and get your transform variable and plug that into where to spawn character.

Below are my blueprints for the MainGameMode and Respawn Actor; I have a transform variable in the MainGameMode blueprint, but I cannot access it in the dying menu blueprint class. I am lost on how should I obtain the transform variable in my dying menu blueprint class from other classes that I have.

1 Like

As you are switching levels, you do need some form of persistence (saving) in place. The reason for this is because GameModes are reset when the level changes and like you mentioned, the Checkpoints don’t exist.

If you want the player’s progress to be reset when the game is closed, this will be very easy. Otherwise, it will require quite a bit more code.

Checkpoints reset on game closed

  1. Make a new GameInstance BP. (GameInstances never change when playing the game).
  2. Give it a Transform variable called Spawn Transform.
  3. Go to your project settings and change your GameInstance to the newly created one.
  4. In the GameMode BP, override Find Player Start function (or something similar), and return the Spawn Transform found in Game Instance (you will need to cast your Game Instance).
  5. Whenever a Checkpoint is triggered, update the Spawn Transform variable in the Game Instance.

Checkpoints not reset when the game is closed
Many ways to do this but a basic way can be using a SaveGame:

  1. Create a new SaveGame BP and add SpawnTransform as a variable.
  2. Override your Game Mode’s Find Player Start and try to load this newly created SaveGame file. If found, use its SpawnTransform, otherwise normal player start.
  3. When a Checkpoint is reached, save the new spawn transform to the SaveGame BP.
1 Like

You can usually use a cast to or “getactor(s)ofclass” to get access to variables in other blueprints. Except for the level blueprint, and may be some others.

In this pic, if you need something from this gamemode bp, then you could trying casting to “whatever_gamemode” and do a “get game mode” and plug that into its obj input.

1 Like

Yes, that should work I would think.