I’m wondering how to stop the local client from responding to a server’s multicast. I’m just not sure what is the best way to do this.
I have a situation where a player can perform an action by pressing a key. The action results in some client-side visual effects and the server then does a few things itself, nothing to special. So here is what I’m doing at the moment.
- Client 1 presses the key.
- Client 1 starts playing visual effects (to hide latency).
- Client 1 calls a “Run on Server” event to notify the server of the action.
- The server validates the action and does a few other things.
- The server then calls a “Multicast” event to notify all clients of the action.
- Client 2 receives the “Multicast” event and starts playing the same visual effects on Client 1’s character.
7. Client 1 receives the “Multicast” event and starts playing the same visual effects AGAIN on its own character.
Step 7 is the problem. I don’t want client 1 (or whichever client triggered the event to begin with) to respond to the multicast event and start playing their visual effects again for a second time. Is there some way to stop the triggering client from responding to the multicast or some way for the client to check if they should ignore the multicast. I could probably get around it by setting a bool or something and checking it again later, but that just seems hacky. I have a feeling there is a better way that I’m not aware of as this surely must be a common problem.