Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

question on unity animations/animator

Discussion in 'Game Design' started by drulz, Mar 29, 2016.

  1. drulz


    Feb 21, 2015

    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?

    2. 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?
  2. JoeStrout


    Jan 14, 2011
    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