Weapon Sway function Replication

Something like weapon sway should pretty much never be replicated and definitely not replicated with a multicast on tick, that’s going to destroy your network for no good reason.

Instead you should just run the weapon sway code locally on each client. Assuming you are using the base character, the player’s rotation is already replicated. A very important rule of thumb when designing for multiplayer is that if you can, you should always base effects on existing signals from the server instead of trying to replicate something new. The cost of re-simulating a couple blueprint nodes is tiny compared to the load you on the game from using a ton of replicated variables.

So, if you have the rotation already replicated on the character (if you don’t yet, you may need to set that up properly), so you should just run the sway calculations on every client on tick. Which is as simple as just connecting the sway code to the tick, no multicasts, run on server etc should be involved anywhere.

Hello, I have a Weapon Sway function that runs on Event Tick and propagates from server to all clients:

It works while on Server or Client, however, it doesn’t trigger when another Client is Spectating (while using SetViewTargetWithBlend) the selected Player, here’s the final function which is being run on the Multicast Event:

So it is working on the Server and Owning Client, but it appears that other Clients aren’t getting the feed.

Also, I have the WeaponSway Component set to Replicate, as well as the variables used.

Appreciate your help, thank you.

Thanks for the tips. Yes, I’m running the code locally without the OnServer and Multicast Events, I thought it would work if I used them.

Still, it’s pretty odd that it doesn’t work, whereas if use something like this inside the function and connecting it to the Event Tick directly, it replicates fine while spectating:

So it must be something related with the code from the original weapon sway? Maybe some variable that is not replicating correctly?

From what I could get, it seems the problem comes from the GetLookUp and GetTurn input nodes, cause if I use a RandomFloatInRange it works just fine