I’m trying to attach a given item’s actor to the character holding it, using a socket I’ve already created in the skeletal mesh’s hand. I’ve verified that I’m calling the following function with the correct socket name (cut & pasted from the editor), but this consistently attaches objects root-root, not root-socket. Is there something obvious I’ve messed up?
void UCharacterInventory::AttachItemToSocket(FName SocketName, AActor* ItemToAttach){
FVector socketLocation;
ACharacter* myCharacter = Cast <ACharacter> (GetOwner());
if (myCharacter != nullptr){
ItemToAttach->AttachRootComponentToActor(GetOwner(), SocketName, EAttachLocation::SnapToTarget);
}
}