Search Unity

Question If I use DirectorUpdateMode.Manual, how can I change rig weight?

Discussion in 'Animation Rigging' started by Sakura_Nekomi, Apr 27, 2023.

  1. Sakura_Nekomi

    Sakura_Nekomi

    Joined:
    Mar 28, 2023
    Posts:
    1
    I`m trying to make a footIK for Generic.
    I set my RigBuilder onOnEnable:

    Code (CSharp):
    1. m_RigBuilder = GetComponent<RigBuilder>();
    2.         if (m_RigBuilder.Build())
    3.         {
    4.             m_RigBuilder.graph.SetTimeUpdateMode(DirectorUpdateMode.Manual);
    5.         }
    But if I used DirectorUpdateMode.Manual,I can`t change the Rig Weight even on Update.
    It will set by Animator.Rebind() ,maybe on ProcessAnimation.

    plz help me ;(

    ps:if I set Weight and used RigBuilder.Build();it`s work,but is it the only one way?
     
  2. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    Welcome to a whole world of pain.

    I have been working with a similar setup for the past 6 months and every few weeks this comes around to really really cause a lot of pain (either animation or rigging not working at all or like right now complete crashes of the engine).

    As far as I can reconstruct it, if you manually evaluate the playable graph you are breaking the interleaving (and threading!) of rigbuilder and animator which causes one of both to write their default values while the other one has already cached their values for the current frame.
    If you let unity just handle this they magically make this work as
    https://forum.unity.com/threads/pla...rformance-best-practices.639511/#post-4284553


    I have a collection of threads dealing with parts of similar problems if you are interested, maybe some of the posts will help you figure out how to work around your problem.
    https://forum.unity.com/threads/exe...te-but-before-constraints-are-applied.933633/
    https://forum.unity.com/threads/bug-possible-conflict-between-rigbuilder-and-sequences.1134019/
    https://forum.unity.com/threads/animation-rigging-with-multiple-animator-layers.1127711/


    If you want to go this route of manually updating you probably need to build the rig graph into the animator graph using
    m_RigBuilder.Build(animator.playableGraph)


    but be warned this crashes the editor for me when disabling and reenabling the character. All in all I would recommend you to just stay away from fiddling with Rigbuilder.Build and manual update mode completely, just let the engine do it's thing, set everything to update as normal in solve your setup some other way.