How to batch Playable graph.Evaluate() from multiple gameObjects?

As described in an old forum https://forum.unity.com/threads/perfomance-problems-of-playablegraph-optimizing-animators.1414872/ - graph.Evalute is a single threaded call ( awaited for multiple animation jobs and graph update for a single gameObject).
We need to batch multiple of those graphs and evaluate them using all available cores.

Is it possible or do we need to completely redesign from scratch all animation and start all over again? ( e.g. DOTS Animation Jobs + custom system and components to apply all the weights\time\animation clip per node onto root gameObject)

It is very frustrating when Unity can’t even see the obvious use cases…

1 Like

if anybody is still interested - you simply switch

Graph.SetTimeUpdateMode( DirectorUpdateMode.UnscaledGameTime );

and in your Update method where you are using actual Evaluate(delta):

_animator.speed = deltaTime / Time.unscaledDeltaTime;

Note:

This is not exactly evaluated as you wish, as PlayableDirector will schedule and batch all of the graphs somewhere from update to LateUpdate - only once per frame.

Additionally - when you have IK - if you are using manually evaluation - your IK Rig should sync target to the Rig ( Rig builder has it’s own Rig internal ECS systems and components) via

      // TODO: This is a separate single thread call ( in the main thread) for each character, see if we can also batch it.
      RigBuilder.SyncLayers();

I’m not quite sure on how to batch that separately and make sure it will be evaluated before the animation graph is evaluated by the director ( in the same frame).

Additionally there is a good explanation on how and when PlayableGraph executes:

Do you mean add _animator.speed = deltaTime / Time.unscaledDeltaTime; before the Evaluate(delta) call? Or replace it?