There’s some workaround that are mentioned in the linked posts above using player controllers or possibly doing it directly on the character per object that requires it
something like this ( stolen from Here1 )
I’ve made an elevator which naturally server owns it… but of course the clients interact with it and unless im doing something wrong never have any way to pass a message to the server
It might be possible with rep notify by having the interface just change an enum ( up, stationary, down ) that is set to rep notify, haven’t tried this yet but i expect rather similar results
TLDR Idk, looking for advice/help it seems like Interfaces should have an option in the details panel to choose to run as Originator or Force Server ( at least on the recieving end of the Interface )
Actual problem in less words… i can’t get the interface to move the elevator for both clients and server
I mean the why makes sense… the how to pass an event not so much
from what i’ve gathered from this post and the 2 linked when i press the key do my line trace and then try and interact… i’ve got to call the actual interact message as the server?
But won’t that mess up any interactions that you might want to happen only on the client
because now all interact events are called as server
Ex client picks up an item as server, from their pov they never get the item only the servers version of their player has the item…
Perhaps the answer is right here in front of me between these three posts but im not seeing it… if you can tell me somewhat step by step so i can put it together and see how it works that’d be tremendously helpful
Client Interacts, There is something to interact with.
RPC Server to attempt interaction. There is something to interact with.
Server calls interface on interacted actor.
Interacted actor is Replicated. Has Enum or other type variable that is replicated.
Actor sets the new value. Replication subsystem takes over and sends the value to all clients copy of the actor.
For doors, elevators use a Repnotify to define a state. Open/closed, up/down/floor# etc.
The OnRep_ function is used to apply the appropriate action based on the value of the repnotify variable.
This seems to be working ( using the 2nd screenshot ), the client can now move the elevator on the server, which multicasts what it does to the clients
Thank you! i’m one step closer to fully understanding replication
IF you are picking up actors you still need the server to do it.
Client wants to pick up an actor. Applies interaction, gets a good result (trace, overlap etc). Determines the actor is a pickup item. Runs a Montage (pickup animation).
RPC server to interact.
Server gets a result, determines its a pickup item.
Server destroys the world actor (replicated actor class). Spawns a replicated actor and attaches it to the owning pawn. Multicast to all Simulated proxies to do pickup animation (montage).
Server would also handle inventory here as well. Inventory Actor component would be replicated as well as the inventory variables (structs, obj refs etc.)
thats correct, and as @Rev0verDrive said you should generally use RepNotify over Multicast.
the reason being MCs can be dropped if not reliable or missed if the Player hasnt loaded yet.
depending on how strict you want to be you could do tests on the Server_Interact to check if the the player can interact or is cheating, for instance you could check if the player is within 100cms. But no need to worry about that nows, its more of the Why its done this way.
Here’s a tutorial I did on Multiplayer interaction. It’s a 4 part series.
Basic interaction setup, Doors, Elevators, Dbl Action doors (swing both ways).
To add to this there’s netcull distance to consider. If I open a door on the other side of a map, All players outside NCD will not get the update. If repnotify is used, then when they enter NCD the update will be sent. Multicasts and RPC’s are one shot events.
Thanks, i will be checking it out, im gonna have to fix the way that i open some chest inventory screens and things now and this will probably help, Currently when i open a chest as a client the server opens it lol
I’ve been using the Network Compendium, looking through the Content Example project and watching countless other videos to try and understand replication… every time i think i’ve got it, it’s never quite right
The tutorial series “explains” the why’s and why not’s that most tuts don’t even mention. Covers Netcull distance and some other things like Proxies too.
Highly recommend you do this in a clean fresh project as a learning process vs directly chopping into your main proj.
I tried watching some of Ryan Layleys videos and Matt Aspland and i think may have actually watched your video at some point when i understood even less than i do now, im watching it now and if i run into more problems that i’m not able to solve i’ll open another question
Sometimes you want the client to be able to do something in another actor, in my case show a containers inventory
When there is a trace that you do not wanna be trusted you just have the server run a trace from the server, such like @Rev0verDrive does in his video and compare the distance or hit actor or whatever you need to
But in the event that the traces are the same, or you trust the result you get back
what i’ve done here is a normal interaction trace and then it sends that same result as the player character and have it run a server interact that will then execute your code you wish only the server to do… Spawn items, move elevators etc
And the client can still do anything else with their line trace and not be limited to dedicated server or client only
Off of my SERVER_Interact event there i will likely impliment some version of the BPI_Trace that i made from @Rev0verDrive 's Tutorial in which i’ll check the results the players trace got and server gets are the same within some small margin
I could be doing something drastically wrong here and this just happens to work or is prone to cheating, tho i can’t see how at the moment ( the client can still remove the items they wish to from the chest, which upon doing so the server removes from it’s copy as well )
Running the interface trace as authority doesn’t seen like it would be best practice but what do i know, I’ve just never seen any other tutorial do so
Data passed to the server from clients is never to be trusted. Nothing is preventing a cheat client from putting whatever it wants in the result. This is why the server should be doing its own interactions.
If you need client only interactions there are other ways to do that.
My project uses GamePlayTags (C++ implementation). Every interactable actor has a tag applied as a config variable. The trace logic has a function to check for a valid tag and return 2 bools and a trimmed tag struct. For example the Tag maybe WorldItem.Weapon.AK47, the function would return the parent ‘WorldItem’ which is used in a Switch to point to the proper functionality for its type.
The booleans are Has Tag and Client Only. The Client Only tag directs the trace logic to a switch to handle client-side only interactions.
The other way, that I am also using is a collision component overlap to fire interface events on the local actor. No input or trace is needed here, just two components overlapping.
All gameplay relevant events should happen on the server. The results replicated down to clients. Looting a chest, picking up an item is part of inventory management. Inventory should 100% be managed by the server.