How to properly replicate ball location (with physics)

I have a ball with physics enabled which runs nice on server,but since “replicate movement/actor” doesn’t replicate objects with physic I have to use an multicast event that replicates the new position to the clients each frame(tick).

This does look good when testing inside editor,but as ping increases you start to see the ball stuttering.

I tried to add Interp to smooth movement over those slower frames,as you can see below…But it just makes it stutter bit differently.

I tried using few diffenert Interp Speeds but with no luck.

You might get better results by adding force on Server through client-to-server RPC, and replicating the ball movement.

Hi did you finaly manage to build your ball replication? I’ve the same problem

I’m stuck on this too, has anyone got a solution?

The problem is with interpolation, your interpolation is based on lagged position and speed, and will always have to “catch up” (which is when the sudden jump/stutter happens).
To properly replicate physics, I think the physics calculations themselves would have to include network smoothing timestamps, which in Unreal Engine, currently they don’t.

There may be a plugin available on the marketplace for this but I’m not sure.

Some people have solved this problem by changing the usual arrangement of the server version of the actor being authoritative, to the client version being authoritative (so the owning client’s version of the simulation doesn’t have to wait for a round-trip update from the server to update the ball position), which with some other techniques allows cheating but eliminates most of the stuttering, as long as the client that owns the ball doesn’t have a bad upload speed.

If this were me facing this problem, AND the ball is supposed to be controllable by a player, like in those Marble Arena
and Monkey-Ball type games, I would try the following first before trying to do the very hard problem of solving network prediction and smoothing for physics engine that doesn’t support it:

  1. Make a new Ball blueprint that is not based on Physics Simulation at all, but is instead based on the CharacterPawn base class.
  2. Make the half-height of the capsule the same as the radius, effectively changing the collision area to that of a ball.
  3. Tweak all the Character Movement and Walking Movement properties of the CharacterMovement component so that it acts as much like a ball as I can get it to (higher inertia, lower friction and deceleration values, etc.
  4. Add a sphere Static Mesh component that fits the collision capsule, and leave the skeletal mesh blank.
  5. Program the spherical mesh to rotate in a way that matches the movement of the ball (detect when it is on the ground or airborne, spin at the rate it would if it was rolling, in the right direction, etc.

But again, ONLY if it is supposed to be controllable by a player.
The CharacterMovement is designed to smoothly predict and catch up lagged network updates across all machines participating, simply by factoring the values used in the Add Movement Input node, the Add/Set Control Rotation node, and the movement mode that is currently active on the CharacterMovement component (walking, swimming, flying, etc.) without you having to implement RPC nodes for each movement.

So this makes it great for networked games, but I am only sure of it for pawns that you want to be able to directly control the movement of.

If this is supposed to be for something like a grenade bouncing off walls and rolling for example, or a pinball or soccer ball simulating around a field, then I’m not sure this will solve the problem for you in the way you need (but you can try it and let me know how it goes)

At some point in time, the default object replication UE4 provides started to work acceptably (with physics).

It still looks like it doesn’t have great client side prediction, but for now it is tolerable.

You could try “Smooth sync” plugin.

Great idea for some cases but N/A for mine unfortunately (soccer ball)…Or at least I didn’t manage simulate movement of a ball.

In that case see if you can find a way to make the Soccer Ball client-authoritative. That means that if you spawn the ball on the client machine then the server obeys that client as to the speed and position of the ball, and reports it to everyone else. I don’t know how to do that, but that is how others have fixed the problem. Just remember it does make cheating possible from the client that is authoritative (of course then cheating is always possible from a listen server then, too)

A further problem with networked physics in Unreal is that PhysX engine is not deterministic, so if you repeat the exact same conditions on another run of the scenario, it may turn out differently, so that makes it even more divergent between multiple machines. I imagine you’ll need to make it so only one machine is simulating and replicating to all the others who are interpolating and predicting ahead. In that strategy it still makes sense to simulate on the server, just not on any other machines, but you may have to create your own network smoothing and prediction.

As Unreal changes over to Chaos physics engine this might be partly resolved, IDK. I just heard things and am passing them on.

Hm,never thought about making it client-authoritative to prevent cheating,but might it be viable as last resort.

For now the ball is spawned only on server (with physics on) and replicated to clients with the default UE4 checkbox…It looks ok but I believe it would brake with more players online.

Yeah, I’m too hoping Chaos brings something new in this department too.