How to respawn the player in C++?

So far I have the player dying after being in a pain causing volume for a while by using the Destroy() function once the health is <= 0. I want to respawn the player at a player spawn point once it’s passed a checkpoint.

I tried using the GameMode->RestartPlayer(Controller) function that I found elsewhere on this site and even tried using A[GameName]GameMode->RestartPlayer(A[GameName]PlayerController) and several variations, but they won’t compile. This was before I wanted to use checkpoints.

What other functions could I use, or do I have to use pointers at some point?

Hi.

Please try this:

GetWorld()->GetAuthGameMode()->RestartPlayer(GetWorld()->GetFirstPlayerController());

Hope this helps.