Can't use attach properly with C++

Attach only seems to work with C++ if i use AttachRootComponentToActor.
The problem is if i use this function, it don’t seem to attach to a socket.
If i , however, try to use AttachRootComponentTo , i can’t use the skeletal mesh as a parent.
it’ll give me this error :

What i don’t get is, apparently i can use this function on BP just fine, and plug the Mesh on the scene component without a problem.
What’s the problem?

You’re likely missing an include as SkeletalMeshComponent does inherit from USceneComponent (down the chain a bit, but its there).

Try adding



#include "Components/SkeletalMeshComponent.h"


That was the problem!! Thanks Matt.