Search Unity

Resolved RigBuilder Manual Update

Discussion in 'Animation Rigging' started by BGCH, Feb 7, 2021.

  1. BGCH

    BGCH

    Joined:
    Nov 23, 2017
    Posts:
    20
    I am using manual animator update so the component is always off. I found that RigBuilder only updates when the animator is enabled. Can I manually update rigBuilder?
     
  2. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
    Hi,

    The RigBuilder is responsible for building the PlayableGraph that will be used in the Animator to post-process your animation. Thus, disabling the Animator will also prevent the RigBuilder PlayableGraph from playing.

    If you want to manually tick the RigBuilder's PlayableGraph, you'll need to retrieve it and change its evaluation mode.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Animations.Rigging;
    3. using UnityEngine.Playables;
    4.  
    5. [RequireComponent(typeof(RigBuilder))]
    6. public class ManualTick : MonoBehaviour
    7. {
    8.     private RigBuilder m_RigBuilder;
    9.    
    10.     void Start()
    11.     {
    12.         m_RigBuilder = GetComponent<RigBuilder>();
    13.         m_RigBuilder.Build();
    14.         m_RigBuilder.graph.SetTimeUpdateMode(DirectorUpdateMode.Manual);
    15.     }
    16.  
    17.     void LateUpdate()
    18.     {
    19.         m_RigBuilder.graph.Evaluate(Time.deltaTime);
    20.     }
    21. }
    22.  
    The RigBuilder still needs to be updated every frame before the animation system evaluates. So you'll want to keep it and the Animator enabled.
     
    BGCH likes this.
  3. Masoverflow

    Masoverflow

    Joined:
    Jan 20, 2013
    Posts:
    5
    Hi,
    I'm trying to get the RigBuilder to work with a PlayableDirector that is set to Manual.
    With both the RigBuilder and PlayableDirector set to manual, seems no matter Update, LateUpdate either the PlayableDirector Evaluate is called last and there is no IK or RigBuilder is called and there is no humonoid animation, the IK targets get positioned and the root motion is there but the character is in the default mucle position.
    What do you think is happening? How can I play a manual timeline in fast forward with RigBuilder IK?
     
  4. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    I am facing the same problem with a generic rig. Depending on what I call last PlayableDirector.Evaluate or RigBuilder.Evaluate only one or the other is works (I guess they override the first one).
     
    Tamago-Jam likes this.
  5. Tamago-Jam

    Tamago-Jam

    Joined:
    Mar 16, 2016
    Posts:
    4
    Similar problem, animation clip track in director's timeline asset will be override by playableGraph created by RigBuilder when start play mode.
     
  6. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    I implemented a solution for my case but it is not simple to recreate as it somewhat decouples the animator and timeline using a new custom animator track (note animat-or not animat-ion).

    You can try to build the playable graph of the rigbuilder into the playablegraph of the timeline and connect it the same way it is connected in the animator usually. The playables api is not beginner friendly and not safe in a way that you have to clean up and manage references yourself pretty thoroughly. At one point I created a situation in which I always crashed the editor when a character got deactivated and reactivated again which went unnoticed for months until it suddenly completely broke everything.
    You absolutely need the playable graph visualizer package (search google / github for it) to understand what is going on.

    I do strongly advise against relying on Evaluate() btw. because it breaks the multi-threading of the animation job according to a few posts somewhere in this forum.
     
    Tamago-Jam likes this.