Search Unity

Question How to mix 2 animators with playable graph?

Discussion in 'Animation' started by Chaiker, Aug 31, 2023.

  1. Chaiker

    Chaiker

    Joined:
    Apr 14, 2014
    Posts:
    63
    I want to use PlayableGraph and mix 2 animators, but it doesn't work and there are no errors or warnings
    everything is displayed in the visualizer
    If the second animator is replaced by AnimationClip for example, everything works fine.
    Maybe someone knows what the problem is?
    https://pastebin.com/p7TF63r0 - code
    Visualizer:
    Unity_2023-08-31_12-46-12.png
     
  2. tsukimi

    tsukimi

    Joined:
    Dec 10, 2014
    Posts:
    80
    I tried using your script, and it works fine(same graph in your img). I can blend between two controller's result.
    Maybe the scond AnimatorController's animation clip isn't compatiple with your model? Can you play each AnimatorController individually on handsAnimator fine?

    (p.s. I slightly adjust your script, but I think there's no difference)
    Code (CSharp):
    1. public class PlayerHandsPlayableController : MonoBehaviour
    2. {
    3.     // I left the animator's RuntimeAnimatorController field to empty
    4.     [SerializeField] private Animator animator;
    5.     // instead of taking controller from Animator, I just directly serialize controllers
    6.     [SerializeField] private RuntimeAnimatorController handsAnimatorController;
    7.     [SerializeField] private RuntimeAnimatorController secondAnimatorController;
    8.  
    9.     // rest is almost same...
    10. }
    (p.s.2 I've just tried the exact same thing 2 weeks ago, what a coincidence!)
     
    Last edited: Sep 2, 2023
  3. Chaiker

    Chaiker

    Joined:
    Apr 14, 2014
    Posts:
    63
    Yes, it worked that way, thank you.
     
    Yuchen_Chang likes this.