How to make actor physics replication work with medium ping

I’ll try not to hijack the thread as I still have things to try and I’ll probably make a post with my findings/approach later, but the StorySoFar™:

Started with kinematic vehicles (similar setup to character movement), worked great for server-auth, responsiveness etc. but was really difficult to resolve collision. Required engine changes to sweep skeletal meshes properly, had to rotate bodies (think turrets) with animation nodes which means no animation optimisations etc. Overall quickly became expensive and doesn’t scale after 10-20 objects. Also hard for remote clients to do extrapolation, and resolving collision is extremely difficult. Acceptable for hovering vehicles, but less so for objects in constant contact with something (think wheels, walkers etc.)

I switched to physics-simulating vehicles and disabled the server corrections. I still send input and transform information to the server (input is used for server-simulation and also replicated to remote clients for extrapolation/visual FX between updates) - and the server does some very simple distance-checks for cheat detection at the moment, as well as detecting illegal inputs. That’s pretty much the extent of it when it comes to anti-cheat for movement. Could pretty easily be bypassed.

The key to anti-cheat is that other gameplay meahcnics can’t rely on client transforms. In my case, weapons and other items always use the server transform for spawning. For this to feel good I added client prediction for projectiles which was an experience in and of itself. TL;DR you can no longer rely on the client for any transform info, so you have to workaround that with other complex systems and learn to live with any inaccuracies.

I have also planned to try spooling up an “immediatte-mode” PhysX scene on the server for each connected client, duplicate all static geometry into it, and simulate client movement in that scene on the server - sending back corrections which the client will also simulate in an immediatte-mode scene and then apply to the main scene. This won’t handle the case where two players are colliding with each other all that nicely, but that’s a generally unsolvable problem anyway until we have quantum internet.

The problem is that going between a regular scene and an immediatte-mode scene is stupidly difficult, requires massive amounts of data duplication and one look at the engines rigid-body anim node (which uses immediatte-mode physx) put me off completely. It’s also way harder than it should be to copy rigid body information between PhysX scenes. They really didn’t make it easy.

One major issue with Physics is that it just does not play nicely with characters (which are kinematic and so treated as infinite-mass by the physics engine). I still feel as though kinematic vehicles are the answer, but they need to scale better and collision needs to be easier to resolve nicely - and the ridiculous amount of code that translates between PhysX and UE4 makes it hard to make that performant.


I’m now essentially waiting for Chaos and the newish Network Prediction Plugin from Epic. The former, I hope, will reduce complexity when it comes to translating between UE4 scenes and Physics scenes - and I hope will be more of a “utility” I can use to resolve collision nicely.

The Network Prediction Plugin isn’t much different to what I have already for my existing kinematic vehicles (shared netcode, separated simulation with input/output buffer etc.) - but it’ll be more refined and, I hope, also be more widely applicable to other gameplay concepts.

3 Likes