Main camera in a minimum default project

I need to change the main camera in a minimum project c++, i have a default camera but i can´t delete this camera and i don´t know create a new camera and set this te principal, the idea is create a new camera no movable and i move the camera by c++ code, how i can create the new camera and set `principal?.

thank you

AFAIK the Unreal default camera will never go away. It is there as a backup in case your code screws up. :cool:

As for your own camera, just create a camera in whatever your main default character class is.


// declare camera in .h file
UCameraComponent* _cameraComponent;

// top of .cpp file
#include "Camera/CameraComponent.h"

// create camera in constructor in .cpp file
_cameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("FirstPersonCamera"));
_cameraComponent->SetupAttachment(GetCapsuleComponent());
_cameraComponent->SetRelativeLocation(FVector(-40.0f, 0.0f, 64.f));
_cameraComponent->bUsePawnControlRotation = true;

i try this but i get a error when compiled :

void USceneComponent::SetupAttachment(USceneComponent *,FName)': el argumento 1 no puede convertirse de ‘UCapsuleComponent *’ a ‘USceneComponent *’

void USceneComponent::SetupAttachment(USceneComponent *,FName)': el argumento 1 no puede convertirse de ‘UCapsuleComponent *’ a ‘USceneComponent *’

y try a recast but i suppose no possible

other Idea is create a cameraActor, in the Actor but when play the aplication,i think the camera move and the proportie movable is set but i don´t see change the camera view