Client replication to server

About a year back i started to make a marble game and it was going great till replication did not work, I eventually gave up and stopped all learning to study for my finals and pass school. I decided to give it another shot but i still cant see whats wrong or what i have to do. So far you click and drag a marble then release it, if you do that on the server the client can see it happen. You can do the same thing on client but the server does not see it move at all. Everything is checked to replicate. I had help with this in the past and no one could figure it out. I’m asking anyone who has knowledge on this to help, im happy to teamview and let you fiddle around with it if you want, anything to get this working.

Checking everything to replicate will not just work.

Replicating means you send variable values (or events) FROM SERVER to client.
To replicate from client to server you need to RPC )remote procedure call) which in unreal is made by “run on server event”

For your game:
client asks (trough calling RPC event on server) to move marble
then server moves marble and replicates it back to client.

This is not quite efficient way because it gets lag problems and warping, but for puzzle game is enough and it is simplest way to do all communication.

Any tutorials or something i could follow to learn how to do this? I have been messing around with custom rpc events but cant seem to get anything to work

custom RPC event needs to meet some criteria:

  • you need to have copy on that blueprint on client
  • you need to have that same blueprint copy (or original) on server
  • client needs to own its server copy (it kind of always owns its copy anyway).

Best place for doing RPC is player controller.

I know some nice tutorial about making session but that is next step after making multiplayer work at all.

Those tuts for general multiplayer problems are so far best i found: Blueprint Networking Tutorials - Unreal Engine

I’ve already watched those videos a billion times trying to wrap my head around this, still have no idea how to use custom rpc events. I don’t understand what part is telling the server that the marble was moved which confuses me on how to use the rpc correctly

There is one big confusing thing in multiplayer blueprints.

Server part of blueprint graph and client part, for most cases are not same blueprint they do not even run on same pc.

To send anything to server you must use “has authority” then send that rpc from client side.
To replicate back to clients you must again use “has authority” buty send this time from server to client (set variables on server, replicate them to clients)

Switch “has authority” basically splits your blueprint into 2 pieces, and you should assume that both of them run in separate instances on separate computers.

For making client on listen server, which is client and server mix and this is only one case when client blueprint runs on same pc (and maybe in same blueprint instance) as server part of code. So for such client you need one additional check, that is if you run really remote client or server mix of client and server.

Can you show how your moving the ball to begin with.

An example of making it move on the server can be seen through calling a function that moves a box sitting on the ground by pressing a button.

Items in use
R press event (controller)
Client press)Custom event run on client (rep)
Server press) Custom event run on server (rep)
Add velocity
Box actor.

  1. Press r
  2. Press event calls client press
  3. Client press calls server press
  4. Server press casts to box actor.
  5. Cast execututs add velocity of z 8000 force.

Box moves for both server and actor.

In this I’m not even using switch authority. I’m calling the action for the server to do for me which is replicated for everyone to see.

Here is my whole marble drag and drop BP my marble drag and drop posted by anonymous | blueprintUE | PasteBin For Unreal Engine

I understand switch authority a little bit but still dont understand when to use an rpc event