- Home /
Animation callbacks and/or events?
I have an animation that runs and I'd like to know when it reaches a certain point, how would I go about doing this?
Answer by dannyskim · Jan 09, 2012 at 08:15 PM
Well the simplest and most intuitive way in my opinion would be utilizing the Animation Events system that is built into Unity. Granted, this animation system works best with animations that are created with the timeline in Unity, but can also be used for imported animations from the program of your choice.
http://unity3d.com/support/documentation/Components/animeditor-AnimationEvents.html
Please note, that any imported animations are going to be set to Read-Only, so you'll have to transfer the animation clip curves to a copy, set the copy as the animation in the editor, and then proceed to add the animation events through the timeline show in the link. A handy dandy script that I utilize heavily can be found here, not authored by me:
http://answers.unity3d.com/questions/8172/how-to-add-new-curves-or-animation-events-to-an-im.html
The more basic and hands on approach would be to keep track of the framerate of the animation through your own callback methods. Unfortunately, through scripting, unity does not have any callback methods associated with animations, so the only way to do this would be utilizing a frame count or time based method to accurately track the progress of animations. I've used this type of system for tracking texture swapping and it has worked pretty much without a hitch if you want to go this route.
Answer by justinl · Sep 25, 2012 at 01:37 PM
I'd like to give a shout out to free iTween package http://itween.pixelplacement.com. It has has a ridiculously easy callback system for code-generated animation. As of this post I believe it's the top free download from the Unity asset store.
Your answer
![](https://koobas.hobune.stream/wayback/20220613062754im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Unity 2D: perform action after animation is done. 2 Answers
Login form: Do I have to set custom delegates to null in OnDestroy? 0 Answers
Animation Event don't show C# methods 1 Answer
How can an editor script know when another script was removed from the project? 1 Answer