Mecanim Trigger event on specific frame of an animation

Without using collision detection, is there a way I can define a “hit” frame within an animation package that can be read by Unity to trigger an event?

I’m using a mecanim generic skeleton and doing the animations in Maya.

While this may not let you get an event to occur on an exact frame of an animation, here is a trick I’ve been using to get a semblance of animation events out of Mecanim.

In Mecanim, you can add data curves to animations that will allow you to pull values from the animation system while its running. (To find out how to work with curves, check out this section of the Mecanim video tutorial

So, for example, let’s say we have a boy who needs to throw a ball. WIth the techniques described in the video, I could add a curve to his throw animation. That curve would start and end the animation at 0, but about the time the boy needs to release the ball, I would make the curve spike up to above a value of 1.

You can then have a script watch and pull this float value from the animator, and if it detects the int value has gone above 1, it can do what it needs to do to populate the ball or do a hit or whatever event you need it to perform. You’ll, of course, need to flush out the code a little bit so that the event only happens once during a single animation, but this should at least help you get going in the right direction.

I’m not overly familiar with mecanim so I can’t be sure if this still applies, I think that this could be done with animation events, which allow you to call a function when a specific animation frame is played.

*Also, if Unity doesn’t let you edit the animation, try making a duplicate of it - you can’t edit animations directly in the imported file, but duplicating it creates an editable animation file.

I think this tool meet your need.

This tool might be better. Just check it out.