- Home /
call a function at a specific frame of animation using mecanin
I have a character being controlled with the mecanin system and i have a script that plays the animation to throw a fireball then instantiates a fireball and shoot it.The problem is it instantiates and shoots the fireball mid animation what i want to know is how to call a function at a specific frame of animation with the mecanin system.Thank you
Answer by GameVortex · Jan 06, 2014 at 10:26 AM
Mecanim now supports Events. Select the Object with the animations in the Inspector, go to the Animation tab at the top. If the animation is set to Generic or Humanoid there will be an Event foldout at the bottom. There you can add events to specific frames and specify what function on the object that plays the animation should be called. You can even add some variables. This is not yet documented properly in the manual.
Thanks do you know which version of unity this was added to
Answer by NikoBusiness · Jan 06, 2014 at 10:12 AM
Use Yield WaitForSeconds(Time); http://docs.unity3d.com/Documentation/ScriptReference/WaitForSeconds.html
or if you are using Unity Pro you can use Mecanim Animation Curves
http://docs.unity3d.com/Documentation/Manual/AnimatorCurves.html
Your answer
Follow this Question
Related Questions
2D Shooting Delay with Animation 2 Answers
Animating Function Calls 0 Answers
How do I change the animation in Javascript? 1 Answer
Animation Event Bug 1 Answer