-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
game:coreCore mechanics on the client and serverCore mechanics on the client and serverneeds investigationThis issue needs further investigationThis issue needs further investigationtype:perfRegarding performance and optimizationRegarding performance and optimization
Description
Consider an accurate way to render the client ahead of the server to mask input delay.
This is a major change, and it requires reworking a lot of internal systems.
🔵 Client Tick
- The client updates its positions in state
- The client sends a snapshot of the positions, current angle, desired angle, and boost state to the server
- The server validates this snapshot
- Check if the player can boost
- Give the client a higher minimum score for boosting to prevent rare desyncs here
- Check if positions are within margin of error of the current snapshot / latest queued snapshot
- If anything fails, clear the queue and rubber-band
- Check if the player can boost
- The server adds the client's snapshot to a queue
🟢 Server Tick
- The server iterates through every player queue
- Pop the earliest snapshot in the queue and update their snake to match
- If the queue is empty, calculate the next snapshot from the current one
- AFTER updating, check if a queue isn't empty for too long; if so, clear it and rubber-band
✏️ Notes
- The client needs its own snake state separate from the server's. This is the best way to prevent interference from the server trying to update it.
- The app needs to render the client version of the snake. This can be handled in the
useSnakesOnScreenhook. It should replace the snake entry for the client with the local version. - Both the client and server need to use the same snake solver. Avoid duplicating logic when trying to implement the snake solver on the client, as this makes it harder to maintain.
- A remote needs to be made to allow the server to force an update on a client.
Metadata
Metadata
Assignees
Labels
game:coreCore mechanics on the client and serverCore mechanics on the client and serverneeds investigationThis issue needs further investigationThis issue needs further investigationtype:perfRegarding performance and optimizationRegarding performance and optimization