Flashcap
Flashcap

Reputation: 141

Where is the camera component located for ACharacter?

So I just started playing around with Unreal Engine 4. I would like to learn as much as I can, so I started with a blank C++ project.

I created a new Character class for my player character, then created a Blueprint based on this class.

The character Blueprint (or some of it's components seem to have a UCameraComponent attached to it, since after making the keybindigs for movement and look up/turn I could already use my mouse to navigate the camera.

My question is, where is this UCameraComponent located? When I open the Blueprint, it seems like it doesn't have a CameraComponent in there. I also tried searching for it in the source code of ACharacter, but couldn't find anything.

enter image description here

I would like to adjust the camera position related to the character because right now this camera is right inside my character mesh.

Upvotes: 0

Views: 1895

Answers (1)

ARtemachka
ARtemachka

Reputation: 143

You have to add it to your class manually.

In YourCharacter.h:

UPROPERTY(EditAnywhere, Category = "Components")
USpringArmComponent* SpringArm = nullptr;

UPROPERTY(EditAnywhere, Category = "Components")
UCameraComponent* Camera = nullptr;

In YourCharacter.cpp constructor:

SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
SpringArm->SetupAttachment(RootComponent);

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

Upvotes: 0

Related Questions