C++ component attachments and deriving to BP

I have started a project in which I’m determined to learn how to use C++ because I’m used to blueprints now and I prefer programming than BP so excuse me if this is a stupid question. I am working on a player character class in C++ and I want to change the camera spring arm attachment from the root to the head socket so I can make the character’s head rotation connected to the camera but I can’t figure out what combination of attachment type and reference I can use to get it to work. I currently just have this since I wasn’t able to get it to work:

FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);

I also am trying to set up the animation BP to my blueprint I’m using that’s derived from this class but whenever I try to cast to the blueprint derived from the C++ class it immediately fails. I know it’s not an issue of my doing the blueprints wrong because I’m doing it just like in the documentation and I have my bp set to autoposses. Thanks in advance!

It tells me my GetMesh() is incompatible with the type USceneComponent because it’s of type USkeletalMeshComponent

It should compile regardless since a USkeletalMeshComponent IsA SceneComponent

Check THIS entry on answerhub. Seems like you have the same problem with him.

wow, that is really aggravating… So the moral of the story is never trust Intellisense I assume?

edit: If you can add this all as an answer I can set it as correct so future people see and you get the karma

Assuming the head socket is a socket you added to the SkeletalMesh and named it “HeadSocket” something like this should work on a character constructor.

	SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Camera Boom"));
	SpringArm->SetupAttachment(GetMesh(), FName("HeadSocket"));

Intellisense is a helping hand, it is the compiler (output log) that is your real friend. Intellisense often gives up if it has to do any deep searching.