AttachToActor is not attaching to socket in C++

Hi,

I have an issue with AttachToActor (C++). I can find the socket, but the attached actor is not inheriting the location from the socket. Am I missing something?

Code snippet:

const USkeletalMeshSocket* MountSocket = Horse->GetMesh()->GetSocketByName(FName(“PlayerMountSocket”));

if (MountSocket != nullptr)
{
AttachToActor(Horse, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), MountSocket->GetFName());

Controller->Possess(Horse);
}

I can manually move the actor like this:

RootComponent->SetWorldLocation(MountSocket->GetSocketLocation(Horse->GetMesh()));

But that is not how it’s supposed to work.