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

Smoother client interactions #2

Open
Vap0r1ze opened this issue Sep 29, 2023 · 0 comments
Open

Smoother client interactions #2

Vap0r1ze opened this issue Sep 29, 2023 · 0 comments

Comments

@Vap0r1ze
Copy link
Owner

The client should be able to predict the result of most actions, so that it can play it's animations when the user interacts, instead of waiting for the server to tell it. There should be some anticipation system, here's my idea of how to do it:

  • Make a map of action types to functions that product predicted events
  • When sending a client request packet, if the request is a predictable one do the following:

  1. Backup the client state along with the new predicted events
  2. Commit the events
  3. When you recieve your next response, created a filtered version of the new events, by filtering out the predicted events.
  4. Commit the filtered events
  5. Now to check that you've anticipated correctly, you need to create two game states to check for equality:
    - settle each unfiltered event to the backed up version of the game state, call this the accurate state
    - settle each event in the event queue to a copy of the current game state, call this the predicted state.
  6. If the stringified json of the accurate game state matches that of the predicted game state, then clear the backup and do nothing. Otherwise, clear the event queue, change the game state to the accurate one.
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

1 participant