Respawn on FellOutOfWorld

I am extending the FPS Project C++ tutorial sample… I want to restart the player at the original player start position if they hit the killz. I want to do this in C++ (not BP).

In AFPSCharacter I override FellOutOfWorld and called:


It doesn’t work though (the player remains at the point where it hit the killz).
It seems from debugging like the pawn gets NULL’d out by the ClientRestart function.

Does anyone know the proper way to restart the player at the player start if they hit the killz height specified in world properties?

You could make a volume actor and simply use an OnHit method call. If it’s true then SetActorLocation to the vector or whatever logic you planned on using.

I’d recommend this way since you could place the volume anywhere which could account for a variety of scenarios.

It sounds like a good idea. In the end I got it to do what I want using:

void AFPSCharacter::FellOutOfWorld(const class UDamageType& DmgType)

	//Teleport back to the player start position.
	APlayerController* PC = Cast<APlayerController>(Controller);
	if (PC)
		AActor* StartSpot = GetWorld()->GetAuthGameMode<AFPSProjectGameMode>()->FindPlayerStart(PC);
		if (StartSpot)

			// set initial control rotation to player start spot rotation
			PC->ClientSetRotation(PC->GetPawn()->GetActorRotation(), true);
			FRotator NewControllerRot = StartSpot->GetActorRotation();
			NewControllerRot.Roll = 0.f;


Its not exactly what I want as actually I want to Destroy() the player actor and this does not do the destroy. If anyone knows the proper way to Destroy() the player on Killz and Respawn ondestroy (via C++) it would be very helpful to add to this thread.


I do something like:

void AMyPawn::TornOff()


void AMyPawn::FellOutOfWorld(const class UDamageType& dmgType)

	bReplicateMovement = false;
	bTearOff = true;


	// Hide and disable the current pawn

Additionally this also needs:

void AMyPlayerController::UnFreeze()
    // or only:
    // GetWorld()->GetAuthGameMode()->RestartPlayer(this);

It seems that ServerRestartPlayer will call RestartPlayer for you. I got this to work, so in case it doesn’t I might have forgotten to copy something important :slight_smile: Also, I’m just a UE noob! So if this may have some unwanted side effects, or if it’s otherwise subobtimal, I would love to hear about it! Oh yea, and I somehow got this from the “Vehicle Game” example at the “Learn”-tab of the laucher.

This worked well for me, thank you!