Attach mesh working on client but NOT on server

Hi guys,

I’m working on a system where the player attaches to a horse (in this case another character). I do this by setting it up on the server, then when the client receives the replicated value it calls the same function.

This is like so:

void AHumanPawn::MountHorse(class AHorsePawn* Horse)
{
	if (!Horse)
		return;	

	Horse->SetOwner(this);
	Horse->Controller = GetController();

	//We let the vehicle move us
	GetCharacterMovement()->Deactivate();

	//Don't collide with anything.
	CapsuleComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);

	//Place it as needed
	AttachRootComponentToActor(Horse, NAME_None, EAttachLocation::SnapToTarget);

	FName SocketName("Mount");
	GetMesh()->AttachTo(Horse->Mesh, SocketName, EAttachLocation::SnapToTarget, true);

	//This also triggers the replication on the client
	CurrentHorse = Horse;
	CurrentHorse->RiderPawn = this;
}

The player mesh is supposed to attach to the horse at a designated socket.

The player mesh attaches fine on the client, but if called on the server the player mesh seems to attach to the root (coordinates 0,0,0). What’s even stranger is if i call this as a blueprint function (overlap on a box) with server authority, it attaches fine! If I eject from the editor it looks fine too. I have no idea what is going on here, any ideas?

Okay, weird. The answer is.

	//Place it as needed
	FName SocketName("Mount");
	AttachRootComponentTo(Horse->Mesh, SocketName, EAttachLocation::SnapToTarget);

	Mesh->AttachTo(Horse->Mesh, SocketName, EAttachLocation::SnapToTarget);

Note I had to attach the root component to the horse MESH , not the horse actor. No idea why this works, but it does.