Hi,
I have units as prefabs, each with an animator and an animator controller.
The controller has 4 states, and 3 layers changing the animations of each state.
When I spawn a unit, I get the warning “Animator is not playing an AnimatorController”. The trouble is that I try to change the weight of the current layer, but the layerCount property give me 0 and GetLayerIndex(name) gives me -1.
I gather something is wrong with the prefab or with the controller.
So far I tried to create an empty controller: same result and to move my prefab from an assetBundle to the Resources folder: same result.
I also tried to do a SetActive on the gameObject once instanciated, do a anim.Play and so on, without luck.
Do you have any idea ?
Thank you
Edit 1:
To explain a little bit how is the process:
step 1: the player choose where to spawn a unit
step 2: I instantiate the model from asset bundle (working fine)
step 3: I check if the unit has an equipment and, if so, step 4
step 4: I instantiate the model for the equipment from asset bundle (working fine) and change the layer from the animator of the unit to match the equipment (barehanded, one handed, two handed, bow…)
So step 4 is not working, I have a few warnings, all linked, when I try to change the layer weight saying “animator not playing an animator controller” (getting layer index, changing weight and so on).
Edit 2:
I’m also looking at Rebind() but with no luck. I will try to rebuild the prefab from scratch, put it in the resources and see if the animator works…