How to add Camera to Character?

I created a class deriving from ACharacter

But there’s no camera: there’s an ArrowComponent, a MovementComponent and a Mesh.

I needed a Camera so I added it through code

Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(RootComponent);

torchLightComponent = CreateDefaultSubobject<USpotLightComponent>(TEXT("SpotLight_Torch"));
torchLightComponent->SetupAttachment(Camera);

Now I have the Camera with a Spotlight attached to it

220506-123.jpg

The problem is: I can’t look up and down anymore!

The InputComponent is set like this:

   InputComponent->BindAxis("Turn", this, &ATCharacter::AddControllerYawInput);
   InputComponent->BindAxis("LookUp", this, &ATCharacter::AddControllerPitchInput);

I can’t understand the problem…

Thanks in advance.

Camera->UsePawnControlRotation=true;

it will be better to create a spring arm component and attach camera to it and set its arm length to 0 if it is for a FP character and also (SpringArm->usePawnControlRotation)

Really thank you! I asked everywhere and none could be able to give me an answer -.-

But you did, thanks very much!