- Home /
Animation Error (Invalid Layer Index '-1')
I'm a bit new to Unity and animations, and am having some struggles.
Invalid Layer Index '-1' UnityEngine.Animator:Play(String) TileMap:CheckWinCondition(Unit) (at Assets/Scripts/TileMap.cs:495) c__Iterator10:MoveNext() (at Assets/Scripts/Unit.cs:227)
In an attempt to make a board game I check to see if the game is over after every move. If someone made a winning move, the game should trigger my "Blue/Red Wins" animation, but I'm getting the above error. From some quick reading it sounds like this could be some weird Unity update thats making things confusing.
My animation is attached to a UI.Text object and is plugged into the script where the "CheckWinCondition" method is called as you can see from the below screen-grabs.
Does anyone have any insight they can share here? I've been failing to fix this problem for an hour with no luck. Normally don't ask many questions, but some help would be really nice here.
Thanks, Stoven91
.
.
.
if (gameOver) {
winnerText.gameObject.SetActive (true);
winnerText.GetComponent<Animator> ().Play ("WinnerAnimation");
}
return gameOver;
}
Object with script containing CheckWinCondition
WinnerText GO
Your answer
Follow this Question
Related Questions
Possible to disable or hide an entire layer of animations? 1 Answer
Root Movement with Additive Layers 0 Answers
Animator Layer executes when weight equals zero 1 Answer
How to layer animations 0 Answers