My animator is creating Simultaneous animation?

前端 未结 1 1731
清歌不尽
清歌不尽 2021-01-29 02:18

I have two characters (enemy) having the same Animator Controller and they play animations Simultaneously. The timing for their animations is exactly the same. Is there a way I

1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-29 03:09

    The issue here is that even if you access the correct instance of the Animator they all still share the same AnimatorController asset.

    => You need a separate individual AnimatorControllers for each instance of the animator.

    You can create them for each instance on runtime e.g. using

    [RequrieComponent(typeof(Animator))]
    public class AnimatorControllerCloner : MonoBehaviour
    {
        [SerializeField] private Animator _animator;
    
        private void Start()
        {
            if(!_animator) _animator = GetComponent();
            var runtimeController = _animator.runtimeAnimatorController;
            var newController = Instantiate(runtimeController);
            _animator.runtimeAnimatorController = newController;
        }
    }
    

    0 讨论(0)
提交回复
热议问题