Camera rotate around player when dead

When the player dies I want him to stop being able to move and instead control a camera that can only rotate around his dead body (as a pivot).

This was very simple in Unity, I created an invactive camera and activated it when the player died and then used RotateAround to use the player’s dead body as a pivot.

I already have a third person camera and spring arm so I thought I might reuse that for the dead camera.

	// First person camera
	UPROPERTY(VisibleDefaultsOnly, Category = Camera)
	UCameraComponent* FirstPersonCameraComponent;

	// Third person camera
	UPROPERTY(VisibleDefaultsOnly, Category = Camera)
	UCameraComponent* ThirdPersonCameraComponent;

	// Arm for the third person camera
	UPROPERTY(VisibleDefaultsOnly, Category = Camera)
	USpringArmComponent* ThirdPersonCameraArm;

Is there a cleaner way to disable player movement without adding branch logic to the movement functions?

void AFPSCharacter::MoveForward(float Value)
{
	if (Controller != NULL && Value != 0.0f)
	{
		// Get the forward vector
		FVector Forward = GetActorForwardVector();
		// Add forward movement
		AddMovementInput(Forward, Value);
	}
}

void AFPSCharacter::MoveRight(float Value)
{
	if (Controller != NULL && Value != 0.0f)
	{
		// Get the right vector
		FVector Right = GetActorRightVector();
		// Add horizontal movement
		AddMovementInput(Right, Value);
	}
}

And how can I use the player’s dead body as a pivot?

void AFPSCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
	Super::SetupPlayerInputComponent(InputComponent);

	// Set up gameplay key bindings
	// Movement
	InputComponent->BindAxis("MoveForward", this, &AFPSCharacter::MoveForward);
	InputComponent->BindAxis("MoveRight", this, &AFPSCharacter::MoveRight);

	// Looking around
	InputComponent->BindAxis("Turn", this, &AFPSCharacter::AddControllerYawInput);
	InputComponent->BindAxis("LookUp", this, &AFPSCharacter::AddControllerPitchInput);
}

at some point you will want to branch the movement logic anyway, based on some kind of movement state. if your character is swimming or climbing a ladder, foward might mean go up, if you have a side scrolling section, foward might mean jump or look up, if you are in a menu, foward might mean move the menu cursor position, or if your character is dead, foward might do nothing. so you should make a state machine based on an enum or name, and branch your logic with switch cases or delegates, because being dead has different controls than walking or swimming.

Thank you. Couldn’t I also create multiple controllers and switch between them? I haven’t been able to find much for example around that though.

i haven’t tried it, but i wouldn’t recommend it. controllers are spawned in the gameMode, and given a pawn during postLogin. it is expected that controllers are consistent throughout a match, while pawns are destroyed and respawned all the time. if you wanted to destroy a controller and spawn a new one, it would have to be done through the gameMode, but it might cause problems with forcing online players to log off.