What isn't said, some missing headers and casting in SetupAttachment

What isn’t said: The inherited FirstPersonCameraComponent and Mesh1P components don’t appear in BP_Character under the CapsuleComponent until after Mannequin.cpp compiles without error.

If you’re using 4.16 or greater, copied all the code directly from the lecture project changes and are having problems compiling:

You may need to add coreminimal.h in mannequin.h:

#include “CoreMinimal.h”
#include “GameFramework/Character.h”
#include “Mannequin.generated.h”

You may need to add CameraComponent.h in Mannequin.cpp:

#include “Mannequin.h”
#include “Camera/CameraComponent.h”

You may need to cast GetCapsuleComponent to USceneComponent:

From this:

FirstPersonCameraComponent->SetupAttachment(GetCapsuleComponent());

to this:

FirstPersonCameraComponent->SetupAttachment((USceneComponent*)GetCapsuleComponent());

Good luck!

5 Likes

Hi all

Thanks for posting
that was a great help
never would have gotten that one.

I also had to add this to the Mannequin.cpp file in order to get the Mesh1P working.

#include “Components/SkeletalMeshComponent.h”

Privacy & Terms