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?
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.
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:
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.
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.