Download

I can't parent FollowCamera to Mesh in player blueprint (C++)

I created a 3rd person template c++ project using ue 4.21.2.

My goal is to make the third person template firsts person by moving the camera forward and re parenting it to the mesh (hierarchically positioning it below the mesh as a child).
Using blueprints, it is as simple as dragging the camera onto the mesh. However, with the c++ project it won’t allow me to do that (The selected component is inherited and cannot be reordered here).

So, I added this code to my CustomCharacter.cpp file:

FollowCamera->SetupAttachment(GetMesh());

However, when I compile the project (no errors) nothing changes. The camera component is not a child of the mesh. It is located in it’s original position on the hierarchy.

I am new to c++ programming, any and all help is appreciated!

You’ll need to recreate the Blueprint most likely. Changing a C++ constructor after creating a blueprint can have unknown effects, especially if you’re changing a call that’s already been made.

Reloading the blueprint fixed the issue. However, I still have a problem.

FollowCamera->SetupAttachment(GetMesh(), FName(“head”));

This code re-parents the camera to the mesh, but it does not attach it to the head socket. Any ideas?

bump. I really could use some help with this.

Have you found any solution? :3