Animation playable output sorting order

Hi,

I know we can set the animation playable outputs sorting order in order to make sure that the Rigbuilder outputs be executed after the Animator’s own outputs but I’m not 100% how.

This is what I have so far:

RigBuilder rigBuilder = GetComponent<RigBuilder>();
for (int i = 0; i < rigBuilder.graph.GetOutputCount(); i++) {
    AnimationPlayableOutputExtensions.SetSortingOrder((AnimationPlayableOutput)rigBuilder.graph.GetOutputByType<AnimationPlayableOutput>(i), 5);
}

I’m also not sure what sorting index to use… So far I haven’t seen any changes when using the previous code.

Thanks!

You could rewrite your bit of code like this:

RigBuilder rigBuilder = GetComponent<RigBuilder>();
for (int i = 0; i < rigBuilder.graph.GetOutputCount(); i++) {
  ((AnimationPlayableOutput)rigBuilder.graph.GetOutput(i)).SetSortingOrder(5);
}

AnimationPlayableOutputExtensions.SetSortingOrder is an extension method, so the first parameter is prefixed with this. This is unfortunately not well highlighted in the documentation.

Otherwise, AnimationRigging already sets the sorting order for all outputs on the RigBuilder PlayableGraph, so you shouldn’t have to set it yourself.

The Animator state machine always takes precedence over all other outputs. Otherwise, the default sorting order for outputs is set to 100, while AnimationRigging sets it to 1000 for each of its output.

The default sorting order index is mentioned here:

Cheers!

2 Likes

Ah ok sounds good! Didn’t realize they were actual extensions methods and not just some utility methods… Makes more sense now!

Thanks for the clarification! The sorting order is definitely a subject that lacks some documentation but your explanation is very clear, thank you!