Whenever i use pooling to disable objects (i.e enemy), the animator is realy going crazy, working badly.
and if im just using Destory(gameobject). everything works fine.
What happens is that i have a fade in animation to the enemy, when i kill the enemy i fade out and disable it after.
but if i respawn that enemy again, it somehow plays the death animation and i cannot stop it from playing.
i literally tried everything you can think about to fix it. i think its a bug.
Pretty sure this error has nothing to do with your mecanim setup or transitions, so probably best to focus on the code.
Since I’m an artist I can’t debug your code properly - but through a process of elimination maybe we can figure it out together.
I don’t see anything that stands out as an obvious error in your code, though I’m an artist so this limitation it’s nearly like reading sanskrit.
Its seems slightly odd - the line if (moveType == MoveType.Air) is in there. Why does the move type matter for the death?
I’m pretty sure this has nothing to do with the error you are experiencing - just thought I’d mention it since it seems oddly placed in the code snippet you provided.
Can you post your respawn code since this is ‘when’ the animation error is happening - upon respawn.
Also consider using the insert code button (3rd button from right in the reply block above) - to post the code. Programmers find this easier to review/debug.
hem, yes i will post all of the code related to the animations, and the “(moveType == MoveType.Air)” is for enemies that fly, such as birds. i did it so when an enemy’s move type is set to Air, then kinematic is true, and when they die in my animation i set it to false so the birds could “fall down” but then more bugs from the setup appeared, so i coded it to be equal to false. but still its not related to the animation.
i dont even think it has something to do with the code since if i disable it manually in the inspector and enable it right again, the same as pooling, the animator still does weird behaviours…
and also the “Die” animation plays even without a transition to it, it only stops to play once i remove it from the animator editor… seems like a bug to me…
anyways this is the full code to when the enemy is respawning (this function is called from the Spawner class on each enemy it spawns): http://pastie.org/10973548
the bool “initialized” is set to true once the enemy first spawns, and after respawning the enemy, it calls Initialize()
once again but now it wont have to grab componenets…
this is the code to when it attacks: https://gyazo.com/9f0175ba939a4e9f8e93c180143c310b
in the code i settrigger and in the setup Attack is a bool, but dont mind that since it doesnt work with both, its just 2 versions of the same project with different setups for the animations…