Download

I can't attach my camera to my mesh

So I’ve been trying a lot to attach my CameraFollow to my Mesh in the Third Person Template but I just can’t find a way. I know that using BP is extremely easy, just drag and drop but in c++ I just can’t get around with it.

I don’t know if you’re still working on this, but it should be pretty straightforward, just setup a spring arm and attach the camera to it.

Have you created a rootcomponent for your mesh? (I assume your mesh is your actor and not something created from ue4 editor?). If you havent, that’s the first step you need to do, once done you need to create a camera component then attach it with your rootcomponent. Dont forget to also setup your camera relativelocation and relativerotation, these allows you to position your camera however you like.

You want to look into using CreateDefaultSubobject() inside your C++ class constructor.

e.g.



CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("MySpringArmComponent0"));
CameraBoom->SetupAttachment(<Your character mesh or something>);


Sorry I am late but I thought no one will answer this anyway, don’t wanna sound dumb but how am I supposed to create a root component for my mesh? I tried this but I still need to create a root component which I couldn’t find on google.

Sorry I am late but I thought no one will answer this anyway, don’t wanna sound dumb but how am I supposed to create a root component for my mesh? I tried this but I still need to create a root component which I couldn’t find on google.

You need to use this->SetRootComponent(/* The component you want to set as root */) within the constructor.

Still can’t get it. What did I do wrong?

Try adding

#include “Components/SkeletalMeshComponent.h”

Are you sure you want to use a skeletal mesh as your root component?
Its collision will change as it animates which will cause all sorts of issues with the character movement component.

The default method for the character is to use a capsule to determine movement, with the skeletal mesh inside of that.

Same error using “Mesh”

I mean, I’m trying to use the default Mesh in order to create a more realistic FPS game. Still same error after including the SkeletalMeshComponent.

Well, after 2 weeks I finally found it, instead of “Mesh” it was “GetMesh()”