NetworkAnimator
A class in Root.Township, Alta.Networking.Animation.
Syncs chosen Animator parameters (floats, ints, bools, triggers, layer weights) from the server to clients as streamed state, and sends the current animation states to joining players. Set values through the Get methods' objects on the server.
- Listed in Networking and servers
- Inherits or implements
NetworkEntityBehaviour,INetworkSerialized,IBuildRendererPostBake,IBuildBakeable - Nested types
FloatParameterType - Attributes
ProfileNetworkSerialized,RequireComponent
Constructors
| Member | What it is |
|---|---|
NetworkAnimator() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
static AccumulativeAverageCount prepareForWriteTimer | Shared profiling timer. |
static AccumulativeAverageCount serializeTimer | Shared profiling timer. |
18 private and internal fields
| Member | What it is |
|---|---|
private Dictionary<string, AnimatedBool> boolMap | Bool parameters by name, used by GetBool. |
private List<AnimatedBool> bools | Synced bool parameters, set in the inspector. |
private Dictionary<string, AnimatedFloatLerp> floatLerpMap | Lerped float parameters by name, used by GetFloatLerp. |
private Dictionary<string, AnimatedFloat> floatMap | Float parameters by name, used by GetFloat. |
private List<AnimatedFloat> floats | Synced float parameters, set in the inspector. |
private List<AnimatedFloatLerp> floatsLerp | Synced float parameters that clients lerp toward, set in the inspector. |
private Dictionary<string, AnimatedInt> intMap | Int parameters by name, used by GetInt. |
private List<AnimatedInt> ints | Synced int parameters, set in the inspector. |
private bool isAwake | Set once EnsureAwake has built the maps. |
private Dictionary<string, AnimatedLayerWeightLerp> layerLerpMap | Lerped layer weights by name, used by GetLayerWeightLerp. |
private Dictionary<string, AnimatedLayerWeight> layerMap | Layer weights by name, used by GetLayerWeight. |
private List<AnimatedLayerWeight> layers | Synced layer weights, set in the inspector. |
private List<AnimatedLayerWeightLerp> layersLerp | Synced layer weights that clients lerp toward, set in the inspector. |
private static Logger logger | NLog logger, used for missing parameter errors. |
private MethodSync syncStart | Method sync made in Initialize that sends the animator state to a player on connect. |
private Dictionary<string, AnimatedTrigger> triggerMap | Trigger parameters by name, used by GetTrigger. |
private List<AnimatedTrigger> triggers | Synced trigger parameters, set in the inspector. |
private Animator unityAnimator | Backing field for Animator, the Unity Animator on this object. |
Properties
| Member | What it is |
|---|---|
Animator Animator { get; } | The Unity Animator on this object. |
bool HasChanged { get; private set; } | True if any synced value changed and needs sending. |
3 private and internal properties
| Member | What it is |
|---|---|
private int Alta.Networking.INetworkSerialized.MaximumBits { get; } | Caps this behaviour's serialized data at 512 bits. |
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.PrepareForWriteTimer { get; } | Returns the shared prepareForWriteTimer profiling counter. |
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.SerializeTimer { get; } | Returns the shared serializeTimer profiling counter. |
Methods
| Member | What it is |
|---|---|
void EnsureAwake() | Builds the parameter lookups, logging any listed parameter the animator does not have. Safe to call more than once. |
void ForceChanged() | Marks the parameters as changed so they are sent. |
AnimatedBool GetBool(string name) | The synced bool parameter with this name. Throws if not listed. |
AnimatedFloat GetFloat(string name) | The synced float parameter with this name. Throws if not listed. |
AnimatedFloatLerp GetFloatLerp(string name) | The synced smoothed float parameter with this name. Throws if not listed. |
AnimatedInt GetInt(string name) | The synced int parameter with this name. Throws if not listed. |
AnimatedLayerWeight GetLayerWeight(string name) | The synced layer weight with this name. Throws if not listed. |
AnimatedLayerWeightLerp GetLayerWeightLerp(string name) | The synced smoothed layer weight with this name. Throws if not listed. |
AnimatedTrigger GetTrigger(string name) | The synced trigger with this name. Throws if not listed. |
override void Initialize() | Sets up the message that sends current animation states. |
override void OnConnected(Player player) | Server: sends a joining player each layer's current state and time. |
void UpdateChanged() | Recomputes HasChanged from the parameters. |
7 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Calls EnsureAwake to build the parameter maps. |
private void LogMissingParameter(string parameterType, string parameterName) | Logs an error when a configured parameter isn't on the Animator. |
private void IBuildRendererPostBake.PostBake() | Build bake hook: initialises every configured parameter against the Animator, logging missing ones. |
private bool Alta.Networking.INetworkSerialized.PrepareForWrite(bool isWriteFull) | Returns HasChanged, so the animator only writes when a parameter changed. |
private void Alta.Networking.INetworkSerialized.Serialize(Stream stream, bool isWriteFull) | Writes or reads floats, layers, ints and lerped values, then bools and triggers behind an any-set flag. |
private void SyncStart(IPlayer player, Stream stream) | Method sync: sends each layer's current state hash and normalized time so a joining client plays the same state. |
private void Update() | Steps every lerped float and lerped layer weight toward its target. |
Used in
Members of other types that take, return or hold a NetworkAnimator:
Agent.animator, Agent.NetworkAnimator, AttackDirectionAnimationBoolSettings.BoolAnimation.Setup, AttackDirectionAnimationFloatSettings.FloatAnimation.Setup, AttackDirectionAnimationLayerLerpSettings.LayerAnimation.Setup, AttackDirectionAnimationSettings.GetNewAnimation, EmptyAttackDirectionAnimation.Setup, IAgent.NetworkAnimator, IAttackDirectionAnimation.Setup, ConsumableLock.animator, AnimatedBool.Initialize, AnimatedBoolAccess.animator, AnimatedFloat.Initialize, AnimatedInt.Initialize, AnimatedLayerWeight.Initialize, AnimatedValue<T>.animator, AnimatedValue<T>.Animator, AnimatedValue<T>.Initialize, WalkerAnimator.animator, MediumBird.Animator, RepairBox.boxAnimation.