Hey, I’m new to programming in UE4 and I’m having trouble with how to code the Camera position using C++. I tried two different ways, but it seems not to be doing the trick. My intentions is to move the camera with the PlayerController class; But, I want to set a default location for the camera when the game has started. Everything I seem to do has failed. Here’s the header code for it.
CPCameraController.h
UCLASS()
class CAMERAPRACTICE_API ACPCameraController : public APlayerController
{
GENERATED_UCLASS_BODY()
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
TSubobjectPtr<UCameraComponent> FirstPersonCameraComponent;
};
and here’s the CPP of it
ACPCameraController::ACPCameraController(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
// Creating the camera component
FirstPersonCameraComponent = PCIP.CreateDefaultSubobject<UCameraComponent>(this, TEXT("CPFirstCamera"));
//FirstPersonCameraComponent->RelativeLocation = FVector(50, 0, 112);
FirstPersonCameraComponent->AddLocalTransform(FTransform(FVector(0, 0, 112)));
}
I have yet write the code to move, but I wanted to see my problem on here first. I don’t know if the reason is because I have the camera in the PlayerController class.