Trying to replicate a Static Mesh Component from a client to all other players

I’ve spent days scouring the internet, and battering chatGPT for help on this. It seems like the solution should be simple but I just can’t figure it out! I’m making a multiplayer FPS shooter (like many others…) I’ve already spent a good few months working with replication so I thought I had a hang of it but at this stage, I’m trying to replicate a Static Mesh Component across all clients (and listen server)

I have an Assault Rifle blueprint, which is a child of the WeaponBase blueprint - in the assault rifle blueprint, I’ve added an empty Static Mesh Component which is meant to change to silencer mesh if the player selects it from a widget. The function works correctly in the Listen Server, of course the listen server automatically updates it to all clients. But if a client changes the static mesh of the silencer it only appears on their screen - not else sees it. I’ve attached some screen shots below of my blueprint setup - would hugely appreciate it if anyone could help out!


Link targets the relevant section (Actor Replication).

2 Likes

Replication is Server to Client, Always. Then engine will not replicate changes on a client to the server or any other client.

Clients must request the server to make the change, then that change can be replicated out to other clients.

2 Likes

On quick glance it seems like it should work. Add some more print strings in there to see where the call isn’t being passed/received. The ARSilencer var being marked replicated is not necessary… you aren’t replicating the mesh, just an int indicating the type of silencer.

Make sure the call is in an actor you have possessed and is allowed to pass rpcs. If you’re calling it on the rifle and it’s not a replicated/possessed actor it wont work. You will need to call this on your player char or maybe player controller.

Halfway down the page outlines the requirements for rpc calls:

1 Like

Hi guys, thanks for the quick responses! I somehow found the solution last night, but still not totally sure how!

It seemed to work correctly when I moved the same code from my Assault Rifle blueprint, over to my character blueprint instead, and from there I set the static mesh on the weapon using the same replication system. I didn’t end up using onRepNotify and just kept the blueprint set up the same