mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-26 18:35:34 +00:00
d7c0c06698
* refactoring
40 lines
977 B
C#
40 lines
977 B
C#
using UnityEngine;
|
|
using UnityEngine.Networking;
|
|
|
|
namespace QSB.Animation
|
|
{
|
|
public class AnimationSync : NetworkBehaviour
|
|
{
|
|
private Animator _anim;
|
|
private NetworkAnimator _netAnim;
|
|
|
|
private void Awake()
|
|
{
|
|
_anim = gameObject.AddComponent<Animator>();
|
|
_netAnim = gameObject.AddComponent<NetworkAnimator>();
|
|
_netAnim.animator = _anim;
|
|
}
|
|
|
|
public void Init(Transform body)
|
|
{
|
|
var bodyAnim = body.GetComponent<Animator>();
|
|
var animMirror = body.gameObject.AddComponent<AnimatorMirror>();
|
|
|
|
if (isLocalPlayer)
|
|
{
|
|
animMirror.Init(bodyAnim, _anim);
|
|
}
|
|
else
|
|
{
|
|
animMirror.Init(_anim, bodyAnim);
|
|
}
|
|
|
|
for (var i = 0; i < _anim.parameterCount; i++)
|
|
{
|
|
_netAnim.SetParameterAutoSend(i, true);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|