Class NetworkAnimator
A component to synchronize Mecanim animation states for networked objects.
Inherited Members
Namespace: Mirror
Assembly: doc.dll
Syntax
public class NetworkAnimator : NetworkBehaviour
Remarks
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 be 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 all animation parameters of the selected Animator. It does not automatically synchronize triggers. The function SetTrigger can by used by an object with authority to fire an animation trigger on other clients.
Fields
| Improve this Doc View Sourceanimator
The animator component to synchronize.
Declaration
public Animator animator
Field Value
Type | Description |
---|---|
Animator |
clientAuthority
Declaration
public bool clientAuthority
Field Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc View SourceOnDeserialize(NetworkReader, Boolean)
Custom Deserialization
Declaration
public override void OnDeserialize(NetworkReader reader, bool initialState)
Parameters
Type | Name | Description |
---|---|---|
NetworkReader | reader | |
Boolean | initialState |
Overrides
| Improve this Doc View SourceOnSerialize(NetworkWriter, Boolean)
Custom Serialization
Declaration
public override bool OnSerialize(NetworkWriter writer, bool initialState)
Parameters
Type | Name | Description |
---|---|---|
NetworkWriter | writer | |
Boolean | initialState |
Returns
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceResetTrigger(Int32)
Causes an animation trigger to be reset for a networked object.
Declaration
public void ResetTrigger(int hash)
Parameters
Type | Name | Description |
---|---|---|
Int32 | hash | Hash id of trigger (from the Animator). |
ResetTrigger(String)
Causes an animation trigger to be reset for a networked object.
If local authority is set, and this is called from the client, then the trigger will be reset on the server and all clients. If not, then this is called on the server, and the trigger will be reset on all clients.
Declaration
public void ResetTrigger(string triggerName)
Parameters
Type | Name | Description |
---|---|---|
String | triggerName | Name of trigger. |
SetTrigger(Int32)
Causes an animation trigger to be invoked for a networked object.
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. |