Intentionally setting StaticMeshComponent's mesh to null doesn't affect replicated clients

anonymous_user_f778e888
Thu, 28 May 2015 19:07:45 +0000
Asset Creation

Setting the mesh to null on the server works, but when the value is replicated to clients it gets ignored. The problem is that OnRep_StaticMesh() sets StaticMesh to NULL before it calls SetStaticMesh(NewStaticMesh). Inside SetStaticMesh there’s an early return for if StaticMesh == NewStaticMesh. Since StaticMesh is NULL and we’re trying to set to NULL it jumps out, never actually updating anything.

void UStaticMeshComponent::OnRep_StaticMesh(class UStaticMesh *OldStaticMesh)
{
	// Only do stuff if this actually changed from the last local value
	if (OldStaticMesh!= StaticMesh)
	{
		// We have to force a call to SetStaticMesh with a new StaticMesh
		UStaticMesh *NewStaticMesh = StaticMesh;
		StaticMesh = NULL;   //  <---Should be OldStaticMesh instead to properly compare

		SetStaticMesh(NewStaticMesh);
	}
}

4 posts - 1 participant