jumpy icon indicating copy to clipboard operation
jumpy copied to clipboard

Interpolate rendered state of game between current state and previous frame's state.

Open MaxCWhitehead opened this issue 11 months ago • 1 comments

Description

I would like to explore interpolating positions of entities for rendering to smooth out the snap we see after a large net correction (or would see on fast moving objects). This problem is usually demonstrated when local prediction of remote player thinks they are moving one way, when they are moving the other. Or after a input is given with high acceleration like jump. After network correction they may teleport over the course of one frame. This is made worse by higher latency as the change in position is greater over a frame.

This is a good reference for how this is to be implemented. I am thinking will save a copy of entity's transforms after game frame (frame as in entire network update loop, real-time frame, not fixed game step), and then save latest transforms, such that we have two to interpolate between. Then will update transform by interpolating between the prev and current based on accumulated time at end of frame, which will introduce up to one frame of visual latency in rendering.

This post mentions predicting one frame ahead, extrapolating instead of interpolating. This may be a good option to avoid this latency, but I have not fully thought through what the implications of this would be yet, not sure if is appropriate.

One tricky part here is keeping the true most recent gameplay state of transform values separate from the interpolated rendered version, and not let these get mixed up in gameplay code. Will think about best way to do this without complicating rendering or gameplay code so they are not confused, should be doable just not sure what the plan would be yet.

MaxCWhitehead avatar Jul 30 '23 00:07 MaxCWhitehead