Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Destroy AnimatorControllerPlayable and keepAnimatorControllerStateOnDisable==true, default pose miss

Discussion in 'Animation' started by StayHungry-StayFoolish, Jun 14, 2021.

  1. StayHungry-StayFoolish


    Aug 2, 2017
    I created a PlayableGraph with an AnimatorControllerPlayable which runtimeAnimatorController is the same as animator's runtimeAnimatorController. when animator.keepAnimatorControllerStateOnDisable is true, and I destroy the instance of AnimatorControllerPlayable, I found that the rotation of the charactor's root was error and unpredictable. I seems to be missing default pose.
    When I set keepAnimatorControllerStateOnDisable = false before destroying the instance of AnimatorControllerPlayable, and set keepAnimatorControllerStateOnDisable = true next frame, it seem that the problem is fiexed. But why will that happen? Can anyone teach me? Thanks.
    Code (CSharp):
    1. m_graph = PlayableGraph.Create( + "_fade_" + m_animator.GetHashCode());
    2. m_graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
    3. m_fadeOutput = AnimationPlayableOutput.Create(m_graph, "fade", m_animator);
    4. m_fadePlayable = AnimatorControllerPlayable.Create(m_graph, m_animator.runtimeAnimatorController);
    5. m_fadeOutput.SetSourcePlayable(m_fadePlayable, 0);
    6. m_graph.Play();
    7. m_fadeOutput.SetWeight(1f);
    9. m_animator.keepAnimatorControllerStateOnDisable = true;
    10. m_fadePlayable.Destroy();  // character’s root node's rotation is error after m_fadePlayable.Destroy()