I’m just wondering if anyone else has come across this, or has any tips on what I’m doing wrong.
I have a main player mesh on a pawn, which is replicated. I manually attach a new mesh to a socket on each instance of the mesh across the network. The final mass however seems completely off. Here’s what I get:
Calling GetMass() on:
Original Mesh = 1.0
New Equipment = 0.0
Final Mesh = 8.07987183
This is consistent across the server and clients.
Here’s my attachment code
UEquipmentComponent* NewEquipment = ConstructObject<UEquipmentComponent>(EquipmentToAttach,this);
if (!NewEquipment)
{
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString("Creating equipment component failed!"));
return;
}
GEngine->AddOnScreenDebugMessage(-1, 30.0f, FColor::Green, FString("Mass of Pawn: ") + FString::SanitizeFloat(StaticMeshComponent->GetMass()) + FString(" : ROLE = ") + FString::FromInt(Role));
GEngine->AddOnScreenDebugMessage(-1, 30.0f, FColor::Green, FString("Mass of new equip: ") + FString::SanitizeFloat(NewEquipment->GetMass()) + FString(" : ROLE = ") + FString::FromInt(Role));
FName SocketName = FName(*SocketNames(int)AttachmentPoint]);
NewEquipment->AttachTo(StaticMeshComponent, SocketName,EAttachLocation::KeepRelativeOffset,true);
NewEquipment->SetVisibility(true,true);
NewEquipment->PlayerPawn = this;
NewEquipment->RegisterComponentWithWorld(GetWorld());
NewEquipment->ReceiverID = UniqueID;
NewEquipment->SetAllMassScale(0.0);
if (AttachmentPoint == EAttachmentPoint::attach_top)
{
equip_top = NewEquipment;
}
if (AttachmentPoint == EAttachmentPoint::attach_right_arm)
{
equip_right_arm = NewEquipment;
equip_right_arm->SetAllMassScale(0.000);
}
GEngine->AddOnScreenDebugMessage(-1, 30.0f, FColor::Green, FString("Mass of new Pawn: ") + FString::SanitizeFloat(StaticMeshComponent->GetMass()) + FString(" : ROLE = ") + FString::FromInt(Role));
I store a reference to the new equipment (child of UStaticMeshComponent) in a variable equip_right_arm. I can see that the mass of that is equal to the final irregular mass. HOWEVER, if I disable the line “equip_right_arm = NewEquipment;” I get the same result for the final Pawn mass.
Any ideas?