I doubt this is your full code, as I think this would show errors before even not working runtime.
Where is your anim
field / variable defined - it is not defined in the class?
Also, in Update, you call animation.Play
so where is that variable in your code? Shouldn’t you be calling anim
?
Also - use code tags when posting, IMHO it is very hard to read code without proper formatting.