Spent a lot of time today fiddling with how physics projectiles from spells work with multiplayer.
-
Spent a lot of time today fiddling with how physics projectiles from spells work with multiplayer. For an agonising time there I could only get 2 out of 3 of the things I wanted working; fixing one broke another.
1. Smooth moving networked physics objects
2. Client prediction so no lag in firing
3. Arcs that matched client aimI was losing hope but finally squeaked in a solution that does all 3 just before the nightly build deadline \o/
-
Spent a lot of time today fiddling with how physics projectiles from spells work with multiplayer. For an agonising time there I could only get 2 out of 3 of the things I wanted working; fixing one broke another.
1. Smooth moving networked physics objects
2. Client prediction so no lag in firing
3. Arcs that matched client aimI was losing hope but finally squeaked in a solution that does all 3 just before the nightly build deadline \o/
Here's a video of my spell test for multiplayer physics objects. Moderate lag (emulation) is enabled. The top window is the server player, the bottom is the client, who is firing the balls. Notice how they appear immediately for the firing client despite the lag (and appear slightly forward on the server). But then they sync up and simulate smoothly and consistently for both, interacting with static geom and other physics objects
-
Here's a video of my spell test for multiplayer physics objects. Moderate lag (emulation) is enabled. The top window is the server player, the bottom is the client, who is firing the balls. Notice how they appear immediately for the firing client despite the lag (and appear slightly forward on the server). But then they sync up and simulate smoothly and consistently for both, interacting with static geom and other physics objects
Also important: the ball hits the wall exactly where the client aiming line indicates that it would, even though beyond the first 0.2s or so the predicted object on the client end gets swapped for the replicated one which has been simulated separately
-
Also important: the ball hits the wall exactly where the client aiming line indicates that it would, even though beyond the first 0.2s or so the predicted object on the client end gets swapped for the replicated one which has been simulated separately
To achieve this I'm using a few things:
- A custom, more accurate server time sync https://vorixo.github.io/devtricks/non-destructive-synced-net-clock/#the-problem-with-synced-network-clocks-in-general
- A system that matches up predicted and replicated objects by an ID communicated at spawn time (like a GAS prediction key but per projectile)
- Manual fixed-time stepping of basic physics trajectory on the server, knowing the time difference
- A smooth sync component I bought years ago which still works better than anything else I've tried https://noblewhale.com/smooth_sync_unreal/ -
To achieve this I'm using a few things:
- A custom, more accurate server time sync https://vorixo.github.io/devtricks/non-destructive-synced-net-clock/#the-problem-with-synced-network-clocks-in-general
- A system that matches up predicted and replicated objects by an ID communicated at spawn time (like a GAS prediction key but per projectile)
- Manual fixed-time stepping of basic physics trajectory on the server, knowing the time difference
- A smooth sync component I bought years ago which still works better than anything else I've tried https://noblewhale.com/smooth_sync_unreal/Out with the boring test spheres, in with the burning, exploding barrels (they don't explode yet, working on it)
-
Out with the boring test spheres, in with the burning, exploding barrels (they don't explode yet, working on it)
*Dambusters music plays*
-
*Dambusters music plays*
I've made the exploding barrels more interesting to use by making the fuse time reduce the longer you hold it fully charged. Much more nuanced and fun than a fixed fuse time (and of course you'll be able to blow yourself up if you hold it too long)
-
undefined Oblomov shared this topic on