Replicate physics movement in multiplayer game (RollingBall)

SOLVED!, see below

Hi all,

So i ran into this issue a couple of days ago, I have a rolling ball PAWN that i can control.
It has basic replication built in but apparently that is only server to client.
That matches with what I see during testing, as the client I can see the servers pawn movements, not the other way around.

I have tried turning replication off and do it manually with a BP but for the life of me I cannot figure out how.
The PAWN has a minigun attached to it that always aims into the direction I’m looking in.
I got the barrel rotation of the minigun replicated propperly and can be seen from both server and client, see picture below:

But replicating the “gun aimpoint” doesn’t work, it can only be seen from the client, so client to server replication isn’t working here:

I have tried a similar setup to replicate the balls movement; by continuously updating a variable en through custom events replicating that to server, from server to all (multicast).
Unfortunately I cannot figure out how to get it to work.

Another thing I tried is to create this whole thing as a character instead of a PAWN, but again the built in replication only works one way.
Turning off physics and do all the movements manually is not really what I’m looking for, it’s more fun for the balls to simulate physics when you run into something or each other.

Please help :slight_smile:

Nobody?

Here is how I move the ball around, I need to get the position and rotation information to everybody that is playing:

when you set your blueprint to replicate did you check to make sure ‘replicate movement’ is checked in the blueprints properties in the ‘replication’ category?

and you need to call a server event when you add the input. so it’s the server who is actually adding the force to the actor and then it replicates to the clients.

This results in terrible controls when there is any sort of latency. See here for a hint towards a solution:

[Video] Player-Controlled Replicating Physics Movement, Simulating Physics! - C++ - Epic Developer Community Forums!

Thank you for your reply, after hours of work I finally got this to work last night! when testing locally the controls are smooth and direct.
However, like Osok says I can imagine this way of doing this will cause latency problems later on.
I’m thinking about “choking” the stream of information to the server (the amount of times it has to add force).
Right now I’m adding a force X every tick, if I would lets say add a somewhat bigger force every 5 ticks you will only have 1/5 of the workload?
The ball will keep rolling between ticks it needs time to slow down so I will have to experiment with the interval.

What do you guys think? am i thinking in the right direction? I’m not an expert on this at all :stuck_out_tongue:
Also, this game will not be a networking expensive game, just simple Deathmatch, TDM and CTF game modes, up to 12 players or so.

For me AddImpulse gives better and more consistent results than AddForce. Experiment and see what works best for you.

Haven’t had time to read every answer, but if you check my Signature, you can find a thread with free projects. There is a project called “BallBump” which is a multiplayer
game with balls. You might want to check that :X At least i hope that’s what you are looking for!

Here is what makes it all ticks; thank you Chooka for the impulse tip, it feels a little better yes :slight_smile:

http://i157.photobucket.com/albums/t56/anonnymous/Unreal%20Engine%204/TheBeast_zps7s1xlr9d.jpg

I want your guys opinions about this graph, any major flaws?
I needed to do some weird stuff to get the client to move it’s babo in the direction of the camera because i wasn’t getting inputAxis values since that is run on server.
Also, what about my idea of only giving an impulse every 5 or 10 ticks to lower server load?

Anyway: full physics, REPLICATED, I’m so excited i shook my own hand haha.

what is the point of break - make rotator? :stuck_out_tongue:

No impuls in the Z direction?

Edit: oh wait, that one, yeah I have some cleaning up to do, that is because all the way in the beginning I was printing strings to see what I was doing.

Physics based replicated movement isn’t easy to do.

To avoid discrepancies, the only option is to simulate locally immediately, and send the ‘moves’ to the server. The server validates and sends them back with a timestamp and simulation delta. The client checks the move that they saved at that timestamp and re-simulates it with the Servers data, and updates the current location. It means that the client is constantly re-simulating old moves after being updated from the server - but it’s the only way to keep all players in sync and allow the client to have responsive controls.

Here’s some good reading on the subject:

Also, this is probably the sort of thing to look at C++ for. Sending input to the server every frame is expensive and there are better ways to compress the data in code.

Whatever you do implement, I strongly suggest simulating it with latency, because I almost garauntee you’ll see different results.

Ok, I have encountered my next problem, I don’t seem to be able to replicate player camera direction properly:

This is how I link the gun arm to the camera direction:

And when I run a custom event the Client to Server replication works, so no local event hapening, on the server you will the see clients gun aim, but that is all.

This will also run this “Event” locally, purely cosmetic if you will; now the client can see his own gun move.

This is where I run into problems, no client to client replication, so when I add a multicast event run from server nothing happens, client 2 cannot see client 1s gun moving, no replication at all.
In the description it says that this will also run this event locally, enabling the server to see its own gun moving, but apparently that doesn’t work either.

As you can see in this short youtube video, when moving the Y axis value is somehow replicated because you can see the gun moving in a weird way.
It is probably linked to one of the pawns axises somehow.

I say “it doesn’t work” but I’m sure it’s not that, I am doing something wrong.
But this is one of the last things I need to replicate before I can move on with this game.

Bumb, see post above.

Hey there,

short reminder: Bumping is not allowed withing 4 days without an answer. So please wait these 4 days before you bump again,
otherwise the forum gets cluttered and others can’t get their threads answered.

Bump, I’d like to know.

This was solved by changing a couple of the project’s config files, for network OSS communication altogether. It started occurring after upgrading the project to 4.25.