How to check if animation state exist

Hello, can someone give me an advice on how to check if a particular animation exist on a gameobject. I have many gameobjects and some of them have an extra animation state. I want the code to check if that extra animation exist then to play it, otherwise it will ignore it. Currently I just order it to play and it is giving me warning that such and such animation doesn’t exist for those gameobjects that doesn’t have it (duh!)… Any advice is much appreciated!

I’m pretty sure a simple if-condition would suffice for that. I.e.:

if(animation["Extra"]){
      animation.CrossFade("Extra");
]

Good luck! =)

Thanks! I got it working now :slight_smile: