Item activation and replication

Hi! I want to add a feature in my multiplayer game. The players have to activate different crystals. So far, it works that I go with the player to the crystal, activate it and the crystal then gives off an energy beam. The problem is that it is not replicated to anyone. Even if it does the host, it will only show to itself.

  • how do you trigger the active crystal
  • how should it be replicated
  • is anything on the crystal being replicated

I’m sorry, I forgot to attach the pictures

  • Where is CE_Execute being called from?
  • Is the thing where CE_Execute is on (I assume the crystal) set to replicate?

The CE_Execute is linked to Event Tick

Two things probably stop your crystal activation to work on all clients:

  • The variable Active needs to be replicated otherwise the clients will never find out that it got activated
  • CE_Process needs to only run on the server

that said, the whole control flow feels off, here is how I would suggest to fix it:

  • The event that calls CE_Process should be on either the playercontroller or the playerpawn
  • This event needs to be set to Run on Server (similar to multicast, just that the call goes from client to server, only works on actors the client owns so it will not work on the crystal)
  • The CE_Process sets the Active variable on the crystal on the server and call UpdateAcitve event
  • This variable is set to RepNotify (similar to Replicated, just that additionally it calls a function when it’s value gets changed from the server)
  • In the OnRep_Active function (which automatically gets created when you set Active to RepNotify) call the UpdateAcitve event
  • UpdateActive is a new event that you create which checks the state of Active and does the stuff you want to do when Active gets set

This flow would not have anything on tick, and uses one RPC to server call + one replicated value ()

As a side node, the CE_Execute Multicast on tick is not a good idea,
what it basically will do is every tick call all clients, who then have to figure out if something happened or not, so a lot of wasted calls

  • if you don’t have a test if you are on the server it will be executed twice, once by being called from the server, and once by being called by the local tick component

… Long Answer, if you have questions I will try to help, but generally, I would recommend reading the Network compendium by Cedric eXi Neukirchen long but helped me a lot.

Thank you very much! I’m not in this whole multiplayer stuff yet, so I do not know much about it yet