I am working on a game system that partly relies on static events and static instance of a class (so not Singleton or static class but just static instance of a class). I am not sure if my system will work correctly when this part of the game is added to multiplayer. I didn't done this before so I don't know will activating a static event for example from one player activate it on all the players or not. Or will referencing that static class from one player reference it on all players.

  • \$\begingroup\$ This depends on the particulars of what these events are, how you've implemented them, and how you handle replication of state to remote clients. Can you show us some details about that? \$\endgroup\$
    – DMGregory
    Oct 3, 2022 at 13:24
  • \$\begingroup\$ I am not the one that works on multiplayer so I am not really sure about that. Currently there is single static event that gets trigger on button press and activates an ability for the player. The thing I am more concern about is static instance for the class. \$\endgroup\$
    – Ivan
    Oct 3, 2022 at 13:58
  • \$\begingroup\$ If it's something that belongs to each player, and the static method does not take an argument that describes which player to use, then I think you're right to be concerned. It's possible this could still work, if the event is only fired locally, and the effects of its execution are replicated by another system, but we'd need to see the implementation to be sure. At the very least, it could cause inconsistencies if you also need to implement events with non-local effects, which you'd then have to remember to invoke in a different way. \$\endgroup\$
    – DMGregory
    Oct 3, 2022 at 15:16
  • \$\begingroup\$ Can you get in touch with the person working on multiplayer, so you can edit your question to show the relevant details? We'll need more specific information to be able to give you definitive answers. \$\endgroup\$
    – DMGregory
    Oct 4, 2022 at 1:20


You must log in to answer this question.

Browse other questions tagged .