Add ContinuousChannel field to NetworkAnimator for split-channel sync (events stay reliable, continuous values opt-in unreliable)#1039
Open
isaiahgrant wants to merge 1 commit intoFirstGearGames:mainfrom
Conversation
… (events stay reliable, continuous values opt-in unreliable).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In games with many concurrent NetworkAnimators (zombie hordes, large-scale RTS, etc.), continuous parameter sync (floats, layer weights, speed) generates steady reliable-channel pressure on every tick. With enough instances this saturates the reliable lane on lossy transports — in our case we hit Steam P2P send-buffer overflow during high-density frames, eventually causing connections to drop.
Our take: The reliable channel isn't the right fit for continuous interpolated values: a missed packet doesn't matter, the next tick supersedes it. But triggers and state changes are one-shots that do need to arrive.
Solution
Add a per-instance
ContinuousChannelfield onNetworkAnimatorthat lets you opt continuous values onto Unreliable while keeping triggers, state changes, and crossfades on Reliable._continuousChannelDefault is
Channel.Reliable, which routes through the original code path bit-for-bit unchanged. Existing projects see no behavior change. The split-channel path is only entered when an instance opts in.ContinuousChannelis exposed as a public property and can be flipped at runtime — useful for distance-based importance (Reliable when close to a player, Unreliable when far).Implementation notes
AnimatorUpdatedSplitwrites to two pooled writers in parallel — same logic asAnimatorUpdated, just routed by category.TargetRpcs and two newServerRpcs carry the streams. Receive logic is shared with the existing path viaReceiveTargetAnimatorPayload/ReceiveServerAnimatorPayload, so deserialization stays identical.Testing
Tested in a 4-player co-op zombie game with up to 300 concurrent NetworkAnimators per host. Reliable-lane pressure on the host's outbound traffic dropped substantially with
ContinuousChannel = Unreliable, and Steam P2P disconnects during burst spawns stopped reproducing. Triggers (hit reactions, attack states) still arrive reliably.