Class NetworkAnimator
A component to synchronize Mecanim animation states for networked objects.
The animation of game objects can be networked by this component. There are two models of authority for networked movement:
If the object has authority on the client, then it should animated locally on the owning client. The animation state information will be sent from the owning client to the server, then broadcast to all of the other clients. This is common for player objects.
If the object has authority on the server, then it should be animated on the server and state information will be sent to all clients. This is common for objects not related to a specific client, such as an enemy unit.
The NetworkAnimator synchronizes the animation parameters that are checked in the inspector view. It does not automatically sychronize triggers. The function SetTrigger can by used by an object with authority to fire an animation trigger on other clients.
Inherited Members
Namespace: UnityEngine.Networking
Syntax
[DisallowMultipleComponent]
[AddComponentMenu("Network/NetworkAnimator")]
[RequireComponent(typeof(NetworkIdentity))]
[RequireComponent(typeof(Animator))]
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class NetworkAnimator : NetworkBehaviour
Fields
param0
Declaration
public string param0
Field Value
Type | Description |
---|---|
String |
param1
Declaration
public string param1
Field Value
Type | Description |
---|---|
String |
param2
Declaration
public string param2
Field Value
Type | Description |
---|---|
String |
param3
Declaration
public string param3
Field Value
Type | Description |
---|---|
String |
param4
Declaration
public string param4
Field Value
Type | Description |
---|---|
String |
param5
Declaration
public string param5
Field Value
Type | Description |
---|---|
String |
Properties
animator
The animator component to synchronize.
Declaration
public Animator animator { get; set; }
Property Value
Type | Description |
---|---|
Animator |
Methods
GetParameterAutoSend(Int32)
Gets whether an animation parameter should be auto sent.
Declaration
public bool GetParameterAutoSend(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index of the parameter in the Animator. |
Returns
Type | Description |
---|---|
Boolean | True if the parameter should be sent. |
OnDeserialize(NetworkReader, Boolean)
Declaration
public override void OnDeserialize(NetworkReader reader, bool initialState)
Parameters
Type | Name | Description |
---|---|---|
NetworkReader | reader | |
Boolean | initialState |
Overrides
OnSerialize(NetworkWriter, Boolean)
Declaration
public override bool OnSerialize(NetworkWriter writer, bool forceAll)
Parameters
Type | Name | Description |
---|---|---|
NetworkWriter | writer | |
Boolean | forceAll |
Returns
Type | Description |
---|---|
Boolean |
Overrides
SetParameterAutoSend(Int32, Boolean)
Sets whether an animation parameter should be auto sent.
Declaration
public void SetParameterAutoSend(int index, bool value)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index of the parameter in the Animator. |
Boolean | value | The new value. |
SetTrigger(Int32)
Declaration
public void SetTrigger(int hash)
Parameters
Type | Name | Description |
---|---|---|
Int32 | hash | Hash id of trigger (from the Animator). |
SetTrigger(String)
Causes an animation trigger to be invoked for a networked object.
If local authority is set, and this is called from the client, then the trigger will be invoked on the server and all clients. If not, then this is called on the server, and the trigger will be called on all clients.
Declaration
public void SetTrigger(string triggerName)
Parameters
Type | Name | Description |
---|---|---|
String | triggerName | Name of trigger. |