Can't find Animator State/Invalid Layer Index in child object inside prefab
Hi,
I've been searching around for ages to fix this issue and so far nobody seems to have the exact same problem. This is my situation:
During runtime I instantiate a prefab which contains a child object (2D sprite). This child object contains a properly setup Animator. I can access the Animator from an external script and get all of it's properties without issue. When i try to play an animation inside this animator using my external script i get the following error messages:
This code is being used to access the child's animator and play the desired animation:
This code works just fine for any other operation performed on the child object.
I've tried many things including specifying the layer using the syntax:
Play (string stateName, int layer, float normalizedTime);
Note! When i place the exact same prefab in the scene and access the child object directly with GameObject.Find everything works perfectly.
Unfortunately i am not allowed to attach more images to this post. I am very sure about the animation name and other variables being correct.
Your answer
![](https://koobas.hobune.stream/wayback/20220612044348im_/https://answers.unity.com/themes/thub/images/avi.jpg)