mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkAnimator
This commit is contained in:
parent
eb4c00f8e4
commit
88bd33a478
1
.gitignore
vendored
1
.gitignore
vendored
@ -62,3 +62,4 @@ ehthumbs.db
|
|||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
|
|
||||||
|
/Assets/Mirror/Plugins/Unity.Cecil.meta
|
||||||
|
@ -3,13 +3,22 @@
|
|||||||
|
|
||||||
namespace Mirror
|
namespace Mirror
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A component to synchronize Mecanim animation states for networked objects.
|
||||||
|
/// <para>The animation of game objects can be networked by this component. There are two models of authority for networked movement:</para>
|
||||||
|
/// <para>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.</para>
|
||||||
|
/// <para>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.</para>
|
||||||
|
/// <para>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.</para>
|
||||||
|
/// </summary>
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[AddComponentMenu("Network/NetworkAnimator")]
|
[AddComponentMenu("Network/NetworkAnimator")]
|
||||||
[RequireComponent(typeof(NetworkIdentity))]
|
[RequireComponent(typeof(NetworkIdentity))]
|
||||||
[HelpURL("https://vis2k.github.io/Mirror/Components/NetworkAnimator")]
|
[HelpURL("https://vis2k.github.io/Mirror/Components/NetworkAnimator")]
|
||||||
public class NetworkAnimator : NetworkBehaviour
|
public class NetworkAnimator : NetworkBehaviour
|
||||||
{
|
{
|
||||||
// configuration
|
/// <summary>
|
||||||
|
/// The animator component to synchronize.
|
||||||
|
/// </summary>
|
||||||
[FormerlySerializedAs("m_Animator")] public Animator animator;
|
[FormerlySerializedAs("m_Animator")] public Animator animator;
|
||||||
// Note: not an object[] array because otherwise initialization is real annoying
|
// Note: not an object[] array because otherwise initialization is real annoying
|
||||||
int[] lastIntParameters;
|
int[] lastIntParameters;
|
||||||
@ -305,11 +314,20 @@ public override void OnDeserialize(NetworkReader reader, bool initialState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Causes an animation trigger to be invoked for a networked object.
|
||||||
|
/// <para>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.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="triggerName">Name of trigger.</param>
|
||||||
public void SetTrigger(string triggerName)
|
public void SetTrigger(string triggerName)
|
||||||
{
|
{
|
||||||
SetTrigger(Animator.StringToHash(triggerName));
|
SetTrigger(Animator.StringToHash(triggerName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Causes an animation trigger to be invoked for a networked object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hash">Hash id of trigger (from the Animator).</param>
|
||||||
public void SetTrigger(int hash)
|
public void SetTrigger(int hash)
|
||||||
{
|
{
|
||||||
if (hasAuthority && localPlayerAuthority)
|
if (hasAuthority && localPlayerAuthority)
|
||||||
|
Loading…
Reference in New Issue
Block a user