Hello, I’m creating a top down 2D Trading card game, I’ve subclased the PC class and copied the code from the topdown c++ template. The problem is that my PC now has two cameras and it’s using the one that it has by default. How can i set my CameraComponent to be the default camera for the PC?
Also is this the best way? I just want a static topdown camera in all the lvls, it won’t move or anything, just render and receive input that doesn’t affect it’s transform.
Here’s my current code:
CardPlayerController.h
UCLASS()
class CARDGAME_API ACardPlayerController : public APlayerController
{
GENERATED_UCLASS_BODY()
/** Top down camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
TSubobjectPtr<class UCameraComponent> TopDownCameraComponent;
/** Camera boom positioning the camera above the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
TSubobjectPtr<class USpringArmComponent> CameraBoom;
virtual void BeginPlay() override;
};
CardPlayerController.cpp
ACardPlayerController::ACardPlayerController(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
// Create a camera boom...
CameraBoom = PCIP.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("CameraBoom"));
CameraBoom->AttachTo(RootComponent);
CameraBoom->bAbsoluteRotation = true; // Don't want arm to rotate when character does
CameraBoom->TargetArmLength = 0.f;
CameraBoom->RelativeRotation = FRotator(-90.f, 0.f, 0.f);
CameraBoom->bDoCollisionTest = false; // Don't want to pull camera in when it collides with
// Create a camera...
TopDownCameraComponent = PCIP.CreateDefaultSubobject<UCameraComponent>(this, TEXT("TopDownCamera"));
TopDownCameraComponent->AttachTo(CameraBoom, USpringArmComponent::SocketName);
TopDownCameraComponent->bUseControllerViewRotation = false; // Camera does not rotate relative to arm
bShowMouseCursor = true;
}
void ACardPlayerController::BeginPlay()
{
}