Hello.
I’ve been writing my own physics based pawn movement for some time now. (for this reason)
It works well but for the last month or so I’ve been tossing around ideas for how to implement client prediction for this movement system.
Specifically, I need a way for the client to reconcile its position with the last agreed one received from the server whilst preserving the effects of all the inputs and movement since the client was at that last agreed position.
To do this, the client should save all the inputs it makes and when the last agreed position and velocity are received from the server, revert to them (since they are to be trusted) and reapply all the inputs and physics executed since then, to avoid the character rubberbanding as that state will be a certain amount of time in the past depending on the latency.
Since making this post, I’ve dug through all the prediction code for CharacterMovementComponent, and found that it uses it’s own pseudo-physics system to manually step a length of physics - as well as step physics normally - which was unfortunately not what I wanted to find as it converges back to the root issue of all this which is that CharacterMovementComponent doesn’t use the built in engine physics.
I can avoid using AddForce and AddImpulse for movement, and instead set velocity directly, but how can I manually simulate physics for a length of time, without actually progressing time? (In a single instant)
I need gravity, damping, and other actors to be taken into account, and I also need impulses to be applied to those other actors.
Alternatively, I’m still open to other ideas for how to save and reapply the input/movement since the last agreed state.
I’m starting to wonder if this is actually even possible…
Thanks.