[Bug]Attach root mesh to other actor component cause wrong mesh relative location

Hi,

I am not sure this is a known bug or UE4 taboo.

Basically, please correct me if I am wrong. If I understood right,

In UE4, if a mesh is root mesh, the world location and rotation will save into mesh relative location and rotation, according the following code

void USceneComponent::SetWorldLocationAndRotation(FVector NewLocation, const FQuat& NewRotation, bool bSweep, FHitResult* OutSweepHitResult)
{
	// If attached to something, transform into local space
	FQuat NewFinalRotation = NewRotation;
	if (AttachParent != NULL)
	{
		FTransform ParentToWorld = AttachParent->GetSocketTransform(AttachSocketName);

		if (!bAbsoluteLocation)
		{
			NewLocation = ParentToWorld.InverseTransformPosition(NewLocation);
		}

		if (!bAbsoluteRotation)
		{
			// Quat multiplication works reverse way, make sure you do Parent(-1) * World = Local, not World*Parent(-) = Local (the way matrix does)
			FQuat NewRelQuat = ParentToWorld.GetRotation().Inverse() * NewRotation;
			NewFinalRotation = NewRelQuat;
		}
	}

	SetRelativeLocationAndRotation(NewLocation, NewFinalRotation.Rotator(), bSweep, OutSweepHitResult);
}

So on client side, the attached actor(weapon) is always spawned in some strange place, then attach character skeleton mesh socket, this relative location and rotation will render attached mesh in wrong position. On server side, it seems attached actor is spawned in origin always, this makes finding this bug very tricky.

The only fix I can do here is NEVER ATTACH ONE ACTOR ROOT MESH TO ANOTHER ACTOR.

Cheers,

Also, my fix is from game side,creating dummy root scene component and make it as parent to mesh component. Later mesh component can be attached to other actor.