Physics based movement over the network, working but issues

This has been driving me mad, I can’t get an accurate way to do this working. I had a very smooth and nice network script working, but I found that it quickly became out of sync between the various clients.

My goal:

  • Client-side physics based movement (because my controls need to be very responsive, can’t wait for server to say “Yes that’s ok”)
  • Replication of this movement to other clients via the server (Doesn’t need to be physics based but does need to be smooth)

What I tried originally:

  • Method: Replication of setting physics values on the characters.
  • Result: Very smooth movement on all clients, responsive, but quickly became out of sync
  • Conclusion: Not a huge surprise, latency would mean the application of the physics values would be timed differently

What I tried to fix this with:

  • Method: Local physics based movement.
    Kinematic replication of character rotation and position on the server, replicated other clients.
  • Result: Actors with “Simulate Physics” can’t have kinematic based property applied to them, so it didn’t work at all.

I then tried using an Authority switch to turn off Simulate Physics on the server side, but this didn’t help as I assume the remote clients still had it enabled so ignored the replicated movement they were asked to do.

I am thus at a loss. How on earth can I do this? I’m sure its possible, I’m just not seeing how!

I don’t have a useful BP to show at the moment as I broke my one badly trying to find a solution. The only working/useful part is the client side setting of Thrust and Angular Velocity based on input.

If you want the Client-Side physics, that’s possible, but you’ll have to regularly send out FORCED World Position & Rotation Updates to the clients from the server as well, otherwise you’ll frequently fall out of sync as you’ve seen already.

This will however result in the ‘Rubber Banding’ effect if the clients get too out of sync and general ‘jitteryness’. Don’t ‘sweep’ the WP-update either, or you’ll cause yourself even more problems. You’ll have to send out a lot more info using client-side physics control, so you either have higher bandwidth usage, or slightly lower responsiveness of controls.

Gamestate updates and rubber banding are probably less preferable than slightly latent controls in most cases :wink:

I’ve come to the same conclusion. Its annoying because rubber-banding is obviously pretty nasty, but when someone has 100ms response times to a server, that makes the controls of a fast paced action game almost impossible to use.

Say, for example, playing Unreal Tournament online. Your movement is run locally, which is why it responds right away, and you jump/rubber-band if you get too far out of sync. The game would be unplayable if you only moved once the server told you you could.

I guess I’ll try the forced update approach and see how it goes.

Worth a try, I’m not netcode expert by any means!

There’s also the option of authoritative server + client side prediction. The server IS in charge of things so that everyone gets the same results, AND the client assumes they can figure things out for themselves, lerping a bit to hide discrepancies.

That’s my most recent try. I run the physics client side, then do a remote function call that runs them server side. When doing any change in movement (thrust/angle/rotation), the server side also sends its world location to the client, which updates it’s world loc based on that. Assuming desync is relatively slow to happen, it shouldn’t be noticed too much.

I may post the complete solution once I have it down smooth and working.

I would like to see this :slight_smile:

After many attempts and different methods I concluded that networked physics based control is beyond me. I’ve seen some people post about managing to do it, but they don’t post how, just the resulting video of it working. It sounds complicated though.

My best method worked mainly ok, but only when the ping was 10ms or less, so really only over a good LAN, making it pretty much useless.

I have reverted to using character movement component, which is physics based to a degree, but is far simpler and handles networking for you very well.

I’ll post my stuff once I have it cleaned up and shiny.

Hello, I have got the same problem here. I hope we can solve it.

I currently have this basic functionality:

  1. In the Character’s BluePrint, I make an event only executed by the server. In that event I enable physics on the desired Character and apply the desired force.
  2. Inside this event, I trigger another event that is a Multicast (executed by all clients). In that multicast event, I do the same as in the server: enable physics and add force.

After that, I guess that in order to interpolate the position and rotation of the Character’s skeletal mesh bones (to achieve faithful replication in all the clients) I need to know information about the position and rotation of the bones (only executed by server), and then store that info in some kind of sctructure (e.g. an array) that is then read by the clients and used in their interpolation.

Problem is, I don’t know how to get the info about the server’s bones and then edit the info about the client’s bones.
How can I read/write the values of a Skeletal Mesh Component?

i tried many times to do something, everytime it fail too

i cant get physics based movement over network too… it start to fail when i add moving platform (lift)