Page 1 of 1

Default Layer Index for AnimatorPlay Sequencer comand

Posted: Thu May 05, 2022 5:53 pm
by laskeys0824
Hello
I am currently using Unity 2021.1.12f1 and Dialgoue System V2.2.23(Ed version) I noticed that I was getting a warning in the console about an Invalid Layer Index '-1'. This caused my animation to not play unless I manually specified the layer that the animation was on. I checked the documentation and the default parameter for the layer is -1. Does it make sense to change the default value for this parameter?
Thanks

Re: Default Layer Index for AnimatorPlay Sequencer comand

Posted: Thu May 05, 2022 6:41 pm
by Tony Li
Hi,

Usually the Invalid Layer Index '-1' occurs when the Animator can't find the named state in any layer.

From the Unity API documentation: "If layer is -1, it plays the first state with the given state name or hash."

The default for AnimatorPlay() is to specify layer -1 so it can find the named state regardless of what layer it's in.