So im new to unreal and i’ve created an actor (character type class) and added 2 cameras to the root node (capsule). As well as a camera boom:
// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->TargetArmLength = 300.0f; // The camera follows at this distance behind the character
CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller
// Create a follow camera
RPGCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("RPGCamera"));
RPGCameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
RPGCameraComponent->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
// Create a FPS camera
FPSCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("FPSCamera"));
FPSCameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
FPSCameraComponent->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
However im trying to switch to the FPSCamera when hitting the jump key (just for debugging) but when I do something like this:
(btw I also have:
/* Player Controller Pointer*/
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
setup in my header file)
void ARPGCharacter::StartJump()
{
bPressedJump = true;
PlayerController->SetViewTarget(FPSCameraComponent);
}
It complains saying “argument of type UCameraComponent is not compatible with parameter of type AActor*”
Do I need to “cast” this or something (Which im still not SUPER familiar with in Unreal). I tried just building and got a lot of
Error C3861 ‘GetPlayerController’:
identifier not
But the only red squiggly in Visual Studio 2019 was within the ->SetViewtarget portion