question on unity animations/animator

hi,

Ive got a couple of questions for unity animations/animator.

  1. with unity, how can we detect hit during middle of animation,
    like say for example, if my 3D character has a punch animation and i want to detect if the punch did hit the target in any part of the punch animation, example during punch scene, halfway in animation it is already connected/hit.

how can we detect it in the middle of animation?
can we add bounding volume or collision volume in animations?

  1. how to detect or trigger something, on a certain animation frame, lie for example during animation end i want to do something, or example in 2D, if i want to trigger some events during a certain frame in sprite?

You can add “animation events” to your animation, which give you callbacks at certain points during the animation. Unfortunately, I have found them to be not completely reliable, in sprite animation at least, though Unity claims that they are, at least until you get near the “exit time” set in your animation controller.

Another way to go is to make a state machine behaviour that runs code at a certain point during the animator state.

I have an article on 2D animation methods in Unity that you may find useful.

Good luck,

  • Joe