Improve movement/camera smoothness with deterministic prediction, ack-aware replay, and tick-aligned input application#9
Conversation
Made-with: Cursor
- Introduced new collision detection logic in the Camera class to improve camera behavior during gameplay. - Added methods for sampling game camera collision distance and determining when to sample based on movement and direction. - Updated EntityManager to include vertical velocity estimation and refined movement direction tracking for better local prediction accuracy. - Adjusted local prediction parameters for horizontal and vertical movement to enhance responsiveness and stability.
- Added new properties to LocalPredictionState for pre-acknowledgment reconciliation and acknowledgment support detection. - Updated initialization and reset logic to incorporate new state properties. - Improved command buffering behavior based on acknowledgment support and pre-acknowledgment grace period. - Refined reconciliation logic to handle pending commands and ensure smoother movement transitions.
- Introduced a new property in LocalPredictionState to track pending speed calibration acknowledgment. - Updated logic to manage speed calibration input sequence numbers during movement command acknowledgment. - Refined speed estimation methods to utilize the new calibration acknowledgment for improved accuracy in movement predictions.
…ion logic - Introduced a new system for handling sequenced movement inputs in the Player class, allowing for better input management and simulation. - Added methods to enqueue and apply queued movement commands, enhancing responsiveness during gameplay. - Updated the Camera class to differentiate collision raycast intervals for mobile and desktop platforms, improving camera behavior based on device type. - Refined movement direction calculations in the DefaultPlayerEntityController to utilize a new deterministic movement resolution method, ensuring smoother character control.
Review notes (mirrored from upstream PR #9)Overall: direction looks solid — deterministic movement parity + ack-aware replay + tick-aligned server input application should noticeably reduce “tug” and jitter. 🚨 Potential correctness issue (camera yaw/pitch can get dropped)On the server, sequenced movement packets are queued, but
Because the client only includes
That can leave the server’s camera orientation stale (movement direction resolution becomes wrong) under jitter / packet bunching. Suggested fix: when consuming a batch, scan the queued commands (from the end) for the most recent defined Compatibility / “old games” risk areas
Performance notes
Suggested manual test matrix
|
- Added a section in the README for simulating network conditions, including parameters for latency, jitter, and packet loss. - Updated the DebugPanel to include new prediction statistics for better debugging of client-side prediction. - Enhanced EntityManager to support local prediction state management, including new properties for motion basis velocity and prediction flags. - Improved input handling in InputManager to accommodate new prediction-related commands. - Updated the NetworkManager to integrate network condition simulation for outgoing and incoming packets. - Refined the Entity schema to include new fields for local prediction state, enhancing synchronization between client and server.
…ng features - Updated ChunkManager to support block prediction and rollback functionality, allowing for speculative block changes on the client. - Introduced raycasting capabilities in ChunkManager to detect block interactions based on ray origin and direction. - Enhanced HytopiaUI with methods to retrieve block data and perform raycasting against rendered chunk meshes, improving user interaction with the game environment. - Added new properties and methods in the server API for local prediction state management, including motion basis velocity and cooldown timers for swimming actions. - Updated documentation to reflect new properties and methods related to local prediction and block management.
Summary
This expands the original client-side prediction work into a more deterministic and stable pipeline for current games, without game API changes.
It improves local movement/camera feel under latency and jitter by aligning client/server movement resolution, tightening replay/reconciliation behavior, and reducing camera/update spikes (including on mobile).
Key Changes
Client
aq).deltaTimeS) is bounded to avoid hitch-amplified prediction error.Server
sq).lastAppliedInputSequenceNumbernow reflects actually applied sequenced input progression more accurately.Network / Protocol
aqfor replay alignment.Camera / Performance
Deterministic Parity Work
Compatibility
Why
Expected Player-Visible Impact