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);
}