pub struct TimeSyncConfig {
pub window_size: usize,
}Expand description
Configuration for time synchronization behavior.
The time sync system tracks local and remote frame advantages over a sliding window to calculate how fast/slow this peer should run relative to the other peer(s).
§Example
use fortress_rollback::TimeSyncConfig;
// For more responsive sync (may cause more fluctuation)
let responsive_config = TimeSyncConfig {
window_size: 15,
..TimeSyncConfig::default()
};
// For smoother sync (slower to adapt to changes)
let smooth_config = TimeSyncConfig {
window_size: 60,
..TimeSyncConfig::default()
};Fields§
§window_size: usizeThe number of frames to average when calculating frame advantage. A larger window provides a more stable (less jittery) sync but is slower to react to network changes. A smaller window reacts faster but may cause more fluctuation in game speed.
Default: 30 frames (0.5 seconds at 60 FPS)
Implementations§
Source§impl TimeSyncConfig
impl TimeSyncConfig
Sourcepub fn responsive() -> Self
pub fn responsive() -> Self
Configuration preset for responsive synchronization.
Uses a smaller window to react quickly to network changes, at the cost of potentially more fluctuation in game speed.
Sourcepub fn smooth() -> Self
pub fn smooth() -> Self
Configuration preset for smooth synchronization.
Uses a larger window to provide stable, smooth synchronization, at the cost of slower adaptation to network changes.
Sourcepub fn lan() -> Self
pub fn lan() -> Self
Configuration preset for LAN play.
Uses a small window since LAN connections are typically stable.
Sourcepub fn mobile() -> Self
pub fn mobile() -> Self
Configuration preset for mobile/cellular networks.
Uses a very large window to smooth out the high jitter and variability typical of mobile connections. This prevents constant speed adjustments that would feel jarring to players.
Trade-off: Slower adaptation to actual network condition changes, but much smoother gameplay during normal mobile network variance.
Sourcepub fn competitive() -> Self
pub fn competitive() -> Self
Configuration preset for competitive/esports scenarios.
Uses a smaller window for faster adaptation to network changes, prioritizing accurate sync over smooth speed transitions. Assumes good, stable network conditions.
Trait Implementations§
Source§impl Clone for TimeSyncConfig
impl Clone for TimeSyncConfig
Source§fn clone(&self) -> TimeSyncConfig
fn clone(&self) -> TimeSyncConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more