Hello, currently I’m working on multiplayer game. I have several objects, like doors and lifts that inherit “Intractable object” interface, but I’ve faced problem that movement and state of these objects don’t share within clients (I mean if I interact with an object on client side it doesn’t move on other clients). I’ve tried to use multicast and (not surprise) it works from server-side, but not client’s one again.
Also tried to change the ownership of the object due to table of RPC’s.
The question is: How to trigger server-side event (custom event with multicast) from client?
Or maybe there some other ways for sharing state of object for all the clients
You need to have the server “Interact” with the actor.
I’m assuming your interact is via key press that does a trace. If so, on successful client trace RPC the server to do it’s own interact trace. On success have it call an event on the interactive actor.
Use Rep_Notify vars in the actor to pass states to clients.
e.g.
Server calls Open event on a door. Open event sets DoorState (enum) to Open. This fires the Rep_Doorstate function. Which calls an event to open the door (timeline, lerp rot etc).
Thanks for your answer but I guess I’m doing something wrong…
I have a lift, that supposed to move, I set the variable “IsAtDownPosition” to replicate mode “RepNotify”, then made an event after interact that toggles that variable. In the OnRep_IsAtDownPosition made a call for the function, but nothing seems to work…
Also tried to change the Replicates mode for “InteractOnServer” event (to make it do smth on client side), but in that case seems like the variable is not updated on server (I mean it seems like the client and server has their own InAtDownPosition variables, that are not related)
Based on this article I tried to call changing the variable from “run on server” event in order to replicate it to all clients, but also nothing seems to happen (it’s obvious, cause client is not server…)
Here I also use RepNotify variable in order to start logic on every client
The result is:
client triggers the server when pressing key → server process the logic of interation → server send information about the interaction to all servers, where this logic is replicated