Hey y’all, I’m a Unity refugee and I’m attempting to learn Unreal 5’s C++. I’ve been scratching my head for a bit now trying to figure out why my camera will not render and instead the engine chooses to render some kind of default camera or something. I’ve copied this code from the Top Down sample and reconfigured it slightly for some input related stuff:
// Fill out your copyright notice in the Description page of Project Settings.
#include "PlayerPawn.h"
#include "Camera/CameraComponent.h"
#include "Components/CapsuleComponent.h"
#include "GameFramework/SpringArmComponent.h"
// Sets default values
APlayerPawn::APlayerPawn()
{
// Set size for player capsule
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);
// Don't rotate character to camera direction
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
// Create a camera boom...
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->SetUsingAbsoluteRotation(true); // Don't want arm to rotate when character does
CameraBoom->TargetArmLength = 800.f;
CameraBoom->SetRelativeRotation(FRotator(-60.f, 0.f, 0.f));
CameraBoom->bDoCollisionTest = false; // Don't want to pull camera in when it collides with level
// Create a camera...
TopDownCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("TopDownCamera"));
TopDownCameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
TopDownCameraComponent->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
// Activate ticking in order to update the cursor every frame.
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.bStartWithTickEnabled = true;
}
void APlayerPawn::BeginPlay()
{
Super::BeginPlay();
}
void APlayerPawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
this->AddMovementInput(this->MovementInput, 32.0f);
}
void APlayerPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis("MovementX", this, &APlayerPawn::MoveX);
PlayerInputComponent->BindAxis("MovementY", this, &APlayerPawn::MoveY);
}
void APlayerPawn::MoveX(float X)
{
this->MovementInput.X = X;
}
void APlayerPawn::MoveY(float Y)
{
this->MovementInput.Y = Y;
}
And the result is this:
It seems like there’s some kind of default camera that is impossible to remove but I’m not sure. Here are my blueprints and settings:
I feel like I’m missing something really obvious. Can anyone help me out?