- Home /
Animator Layer executes when weight equals zero
I was reading the documentation about the Animator and its layers and it says:
When the weight of the layer is zero, Unity skips the layer update.
https://docs.unity3d.com/Manual/MecanimPeformanceandOptimization.html
My understanding is that Unity doesn't execute anything in the layer (disables the layer), since Update means usually every frame.
So I tested it. Created two layers, Base and a New one. With only one state each.
And the progress bar is moving in the New Layer. And then I thought it would only be a visual thing because of the Speed field in the Inspector, so I created a Behaviour in each State (in the two layers), Base Layer is B ONE and New Layer is B TWO.
override public void OnStateUpdate
(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Debug.Log("B ONE");
}
And both execute even when New Layer weight is zero. The Sync function doesn't seem to affect the execution, when the layers are sync or not sync the result is the same.
Am I missing something?
Answer by MisterKidX · Oct 11, 2020 at 10:37 AM
@nunomcards This is because the documentation is WRONG, unity stated so themselves in one of the Unite conferences (and lord knows why it hasn't been fixed). In truth, animation layers, even when set to 0, are evaluated and are very costly concerning CPU time. each layer adds about 20% of CPU time; again, even when at weight 0.