com.unity.netcode.gameobjects
com.unity.netcode.gameobjects copied to clipboard
feat: Added support for client anticipation in NetworkVariables and NetworkTransform and support for throttling functionality in NetworkVariables
Changelog
- Added: Added
AnticipatedNetworkVariable<T>, which adds support for client anticipation of NetworkVariable values, allowing for more responsive gameplay - Added: Added
AnticipatedNetworkTransform, which adds support for client anticipation of NetworkTransforms - Added: Added
NetworkVariableBase.ExceedsDirtinessThresholdto allow network variables to throttle updates by only sending updates when the difference between the current and previous values exceeds a threshold. (This is exposed inNetworkVariable<T>with the callbackNetworkVariable<T>.CheckExceedsDirtinessThreshold) - Added: Added
NetworkVariableUpdateTraits, which add additional throttling support:MinSecondsBetweenUpdateswill prevent the NetworkVariable from sending updates more often than the specified time period (even if it exceeds the dirtiness threshold), whileMaxSecondsBetweenUpdateswill force a dirty NetworkVariable to send an update after the specified time period even if it has not yet exceeded the dirtiness threshold. - Added: Added virtual method
NetworkVariableBase.OnInitialize()which can be used by NetworkVariable subclasses to add initialization code - Added: Added virtual method
NetworkVariableBase.Update(), which is called once per frame to support behaviors such as interpolation between an anticipated value and an authoritative one. - Added: Added
NetworkTime.TickWithPartial, which represents the current tick as a double that includes the fractional/partial tick value. - Added: Added
NetworkTickSystem.AnticipationTick, which can be helpful with implementation of client anticipation. This value represents the tick the current local client was at at the beginning of the most recent network round trip, which enables it to correlate server update ticks with the client tick that may have triggered them.
Testing and Documentation
- Includes integration tests.
- Includes documentation for previously-undocumented public API entry points.
- Includes edits to existing public API documentation.