Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MaxCWhitehead opened this issue Jul 30, 2023 · 1 comment

Comments

@MaxCWhitehead
Copy link
Collaborator

MaxCWhitehead commented Jul 30, 2023

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.

@zicklag
Copy link
Member

zicklag commented Jul 30, 2023

I'm totally open to any kind of exploration here so feel free to try whatever technique you can get working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants