Is there a way to implement a simple-ish multiplayer system without having the replication events on the player characters themselves? Im curious about this mainly because i already have a lot of code crammed in there mainly to do with character movement and except the basic walking and looking around (yaw only,pitch doesn’t replicate)nothing else replicates and i really dont want to have three separate event for every movement mechanic.
I’ve looked everywhere for a better mp tutorial than the ones in youtube but in every single one they put the call to server events on the character and at this point im done trying to figure out if there is a way to bypass authority and still have the events replicated (sort of like a simulated lan?idk) or a better way to put it would be where everyone has authority but something else like the level blueprint or the game instance is keeping track if everything is synced.
Its a pretty wordy question already and im sorry for that but to summarize:
Im trying to create a mp system with a “fake” dedicated server hosted on the game instance/lvl bp just so that i can avoid having the call for event replication code on my player character because its already pretty stuffed and im nowhere finished with it.
Tl;dr2 : if you have any ideas how i can move the event replication code anywhere else instead of the player character please tell me im desperate
Hi, you should do all logic that is relevant for all clients server side and only send the player input from the client directly to the server, but generally nothing else. Since you handle the player input either in the player controller or the controlled pawn it makes sense to put the RunOnServer RPCs there instead of anywhere else.
and i really dont want to have three
separate event for every movement
mechanic.
Not quite sure what you mean. Make a new enum with entries like “walk”, “jog”, “sprint”, “crouch”,… Then create a variable of that inside your character and mark it repnotify. Then you only need one RPC for the client to tell the server the new movement type. And when it gets changed on the server, all clients and the server will automatically execute the function associated with the repnotify enum variable.
Replication from the server to the clients will work on any actor that does replicate (and also exists on that client). And since you generally should do all game relevant logic on the server and then use replication so that the clients see the results, you can use replication in those actors where you need it (and not put it all in the player character…).
As for the client telling the server to do something (RunOnServer RPC), then you can only do that when the client that owns that actor calls it. Therefore most of the times you would do that either in the player controller or inside the controlled pawn. Since generally you would only call RunOnServer RPCs to directly send the player input to the server and then do everything server side, you would call that event where you handle the player input. Since that would be either the player controller or the controlled pawn, then I don’t see much of a problem doing it there.