You will need to #include your character’s header in the cpp.
This should work… hope it helps.
#include "<put your character's header in cpp>"
// Called when the game starts
void UMyActorComponent::BeginPlay()
{
Super::BeginPlay();
// Get the owner of this component
AActor* CharacterOwner = GetOwner();
// Cast the owner to my character
AMyCharacter* MyCharacter = Cast<AMyCharacter>(CharacterOwner);
// check the cast is valid
if (MyCharacter )
{
// Get the bone of interest.
// Double check in PERSONA that name and spelling match!!!
FName HeadBone = "Head";
FVector BoneLocation = MyCharacter->GetMesh()->GetBoneLocation(HeadBone,EBoneSpaces::WorldSpace);
UE_LOG(LogTemp, Warning, TEXT("Head bone location is : %s"), *BoneLocation.ToString());
}
}