Execute script after Mecanim animation?

Is it possible to run a script after each loop of an animation?

For example : I want to play a particle effect after every hit to a rock with a pick axe. So this animation is in a loop.

I could just play particle after a certain amount of time but that doesn’t seem very efficient when trying to get it at the exact moment the animation loops (hits the rock).

You can set Animation event in animation settings

you can add colliders to axe and rock. Then check for the collision between them. Instantiate your spark inside it

29751-capture.jpgyou can attach the script to the game object with the animation and then animation tab select add event key at your desired key frame and select your function from the add animation event window

I figured it out on my own. Events for Mecanim Animations are put in the same place you find Animation Curves in the newest version of Unity 4. Under Events you can specify a function at a key-frame. The function will be triggered on whatever game object is playing the mecanim animation.