Multicast not firing
I've got a small setup where player can apply a camo to their weapon. Since other clients need to see the Camo too, i've made a small multicast function that sets the players camo for that client, and all other clients:
Once a player picks up a camo paint, upon using it the following function is called:
The problem is that the WeaponCamo actor cannot call the Multicast function. It will be called on the local client, but won't get called on the other clients too, which is what a Multicast is supposed to do.
Anyone know what is happening? I have a feeling it is due to Ownership, but not sure what the solution is here.
asked Jan 12 '17 at 04:49 AM in C++ Programming
So there are two common patterns to follow for multiplayer programming:
Have the client execute a Run At Server RPC to get from the Client to the Server. Then run a Multicast RPC on the server to replicate an event to all clients.
This method is good for temporal things. Things that happen, but then disappear, such as particle effects and animation montages.
The second pattern is to have the client execute a Run At Server RPC to get from the Client to the Server. Then have the Server change the value of a Rep Notify variable. Then when the variable value is replicated back to the Client, an OnRepNotify function is called on the client to allow you to change whatever it is you need to change on the client.
The second pattern is much better for permanent changes because unlike the multicast it will maintain state. I think in your case since you want the camo to stay set for more than just a few seconds,you probably want to go with the second pattern. From your code I can't tell if you are missing the initial Run At Server RPC to get from the Client to the Server. If so, then that is probably why your multicast isn't working. But even if you get it to appear like it is working with a Multicast, I have a feeling it will work intermittently until you switch to a Rep Notify variable instead.
If you have any questions about the difference between the two, take a look at this video on Network Relevancy that explains the difference between Multicast and Rep Notify:
answered Jan 12 '17 at 05:33 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here