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

Figure out solution for latency "issue" #4

Open
ivozilkenat opened this issue May 7, 2024 · 0 comments
Open

Figure out solution for latency "issue" #4

ivozilkenat opened this issue May 7, 2024 · 0 comments
Assignees

Comments

@ivozilkenat
Copy link
Owner

Goal

It is not feasible to update client state whenenver the server receives an update. Therefore a solution for that has to be implemented.

Client-Side Rendering Logic

On the client side, smooth implementation involves not just rendering the states received from the server but also predicting and interpolating movements to counteract the effects of network latency and ensure smooth animation. Here's how it's typically done:

Prediction

  • Purpose: To reduce the impact of latency, the client can predict where a player or object should be between updates based on its last known state and direction of movement.
  • Method: Using basic physics or simply extending the current trajectory of moving objects, the client can estimate positions ahead of the next server update.

Interpolation

  • Purpose: To smooth out the movement of objects between updates received from the server.
  • Method: If an object’s position is reported at point A in one update and point B in the next, the client will gradually move the object from A to B in a linear fashion over the time between updates. This makes movements appear smoother and less jumpy.

Extrapolation

  • Purpose: Similar to prediction but used when updates from the server are delayed or lost.
  • Method: The client assumes movement along the same trajectory and speed if an update is missed, adjusting when the next update is received.

Frame Rate Independence

  • Handling: The client's rendering and game update loops should operate independently of the network update rate. Ideally, the client should render at the highest frame rate supported by the hardware (e.g., 60 FPS or higher).
  • Technique: The client uses the game state from the last update and any interpolated or predicted states to render each frame, providing smooth visual performance regardless of network conditions.

This combination of techniques helps maintain a responsive and visually appealing experience, even when actual network conditions vary or degrade, making the 100 ms update rate a viable choice for many multiplayer games.

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

No branches or pull requests

1 participant