Changing Skeletal Mesh component in Server function

Inside the character class I made a server function which changes a skeletal mesh component of the character:

UpperBody_Gear->SetSkeletalMesh(PickupItem->SkelMesh_Gear_Male);

But so far the component only changes on the server. How can I make it so it also changes (replicates) on all the clients aswell?

Thanks in advance.

There are several ways to perform what you do. You can set a replication value to be send to the client that represents the mesh, for instance just a simple int value, and depending on the value the client will set the right mesh. Another ways is to configure the mesh in your PickupClass, in it’s defaults for example. Then when you pickup the item you can send the class to the client via functional or variable replication and get the right mesh from there, the idea is that the class holds a ref to the mesh. The final implementation varies depending on your pickup system though.

The idea of all ways is always a way to tell the client what to do, and not only the owning client but all the other clients in the match. Using variable replication will make the broadcast of the mesh easier because the engine can replicate it directly.

Hey Moss,

thanks for your answer!

For clarification’s sake, “UpperBody_Gear” is a SkeletalMeshComponent in the Character class. In the Characters constructor this component’s replication is activated (UpperBody_Gear->SetIsReplicated(true):wink:

The “PickupItem” is another Actor, which holds a SkeletalMesh reference (SkelMesh_Gear_Male). In the PickupItem’s constructor, replication is activated (SetReplicates(true):wink:

Now when I change the SkeletalMeshComponent in the Character class, it should replicate its changes to the clients, right? Or am I missing something here?

Nevermind… I added a NetMulticast function and executed it inside the server function to update the components on all the clients.

I have the same problem.
it seems that it only occurs when using skeletal mesh component.

1 Like