Search Unity

Bug Transitioning to a AnimatorControllerPlayable (PlayablesAPI/Animancer)

Discussion in 'Animation' started by LeFlop2001, Dec 28, 2021.

  1. LeFlop2001

    LeFlop2001

    Joined:
    Jan 30, 2020
    Posts:
    11
    I recently tried using the PlayablesAPI to transition from an animator to a animationclip and back. However, I ran into a problem where:

    The Problem
    When you transition to a previously connected AnimatorControllerPlayable using a AnimationMixerPlayable all AnimationPosePlayables in said animatorController seem to break, and instead of the animationpose from the interrupted transition Mecanim transitions from a default pose.

    I successfully recreated the problem in a new project by creating a new animator controller with an transitioninterruption and transition to it.

    PlayablesAPI:
    Code (CSharp):
    1.  
    2. void Start()
    3.     {
    4.         var animator = GetComponent<Animator>();
    5.  
    6.         var graph = PlayableGraph.Create();
    7.         graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
    8.  
    9.  
    10.         var mixer = AnimationMixerPlayable.Create(graph, 1);
    11.         var animContr = AnimatorControllerPlayable.Create(graph
    12.         , animator.runtimeAnimatorController);
    13.  
    14.         mixer.ConnectInput(0, animContr, 0);
    15.         mixer.DisconnectInput(0);
    16.         mixer.ConnectInput(0, animContr, 0);
    17.  
    18.  
    19.         var output = AnimationPlayableOutput.Create(graph, "output", animator);
    20.         output.SetSourcePlayable(mixer);
    21.  
    22.         graph.Play();
    23.     }
    24.  
    Animancer:
    Code (CSharp):
    1.  
    2. void Start()
    3.     {
    4.         var animancer = GetComponent<AnimancerComponent>();
    5.         var runtimeAnim= GetComponent<Animator>().runtimeAnimatorController;
    6.  
    7.         var animContrState = new ControllerState(runtimeAnim);
    8.         animancer.Play(animContrState).Events.OnEnd =
    9.         () => animancer.Play(animationClip).Events.OnEnd =
    10.         () => animancer.Play(animContrState);
    11.     }
    12.  
    In Animancers case it alse leads to freezes and time jumps in addition to the previously described problem.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    I just tried your Animancer code and it seemed to work fine with no unexpected poses, freezes, or time jumps. Can you post a gif showing what's actually going wrong for you (with the Inspector visible)?

    Also, you shouldn't be using an Animator Controller assigned to the Animator component and in a ControllerState at the same time. It shouldn't cause any problems, it's just a waste of performance to run two copies of the Animator Controller when only one will actually affect the model.
     
  3. LeFlop2001

    LeFlop2001

    Joined:
    Jan 30, 2020
    Posts:
    11
    @Kybernetik thanks for the reply.

    Mecanim (Normal):

    This is the expected behavior when just using an animator. It transitions from its idle to the kick animation,after which said animation is then interrupted by an exit transition.

    Animancer (Freezes):

    This is what i meant by freezes. After reviewing it somemore i came to the conclusion that its not a bug but rather the exit transition missing its exit time (sorry). The interresting that it seems to happen more consistently when using Animancer.

    Post Animator Transition(Bugged):

    This is what happens when i reattached an AnimatorControllerPlayable (PlayableAPI or Animancer). As you can probably tell, instead of the animation pose it transitioning from a default pose after interrupting.

    I uploaded the the test project i used to github:
    https://github.com/JaggedToTheMax/PlayablesAPI-Bug
    Note that i deleted playableGraphVisualizer because i had upload issues and the character in the normal scene still has a BuggedAnimancer and Animancer Component (which he should not but i am to lazy to fix it).
     
    Last edited: Jan 2, 2022
  4. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Are you sure every state in the Animator Controller has a Humanoid animation? That's the pose I would expect to see if you fade a Humanoid Rig from no animation (or a Generic animation) to an actual animation. Otherwise I don't know of anything that could cause it.
     
  5. LeFlop2001

    LeFlop2001

    Joined:
    Jan 30, 2020
    Posts:
    11
    Wierd right? But yes, i personaly made sure of it.
    After all it works fine in the first to clips and all three of them are using the same controller.
     
  6. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Have you reported a bug via the help menu?
     
  7. LeFlop2001

    LeFlop2001

    Joined:
    Jan 30, 2020
    Posts:
    11
    No, I wanted to make sure i wasnt using the api wrong. but i will now.