- Home /
StateMachineBehaviour is working weird with AnimationClip.AddEvent
So, StateMachineBehaviour.
using UnityEngine;
using System.Collections;
public class AnimatorStateBehaviour : StateMachineBehaviour {
void OnStateEnter() {
DoSomething();
}
it will fire once when animator is entering any status. right? it should fire once. but it's working weird when I'm trying to use 'AnimationClip.AddEvent'. in it.
using UnityEngine;
using System.Collections;
public class AnimatorStateBehaviour : StateMachineBehaviour {
void OnStateEnter()
{
AnimationEvent evt = new AnimationEvent ();
evt.functionName = name;
evt.time = time;
... get clip from AnimatorClipInfo ...
someClip.AddEvent (evt);
}
now I've added 'AnimationClip.AddEvent'. and let's play it.
well... it goes crazy.
this thing fire function every frame! what's wrong with this? I can't use AddEvent in StatusBehaviour?
Do you have any idea what is wrong with function? any comment will be very helpful.
Thank you!
Your answer
![](https://koobas.hobune.stream/wayback/20220612061728im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to prevent an animation from triggering more than on due to fast clicking? 2 Answers
What would be the best way to do something based on the animation state of the character? 0 Answers
why I have to anim.getComponent in update() function when I had done in Start () function 2 Answers
Problems with player movement animation 0 Answers
How to trigger different animations depending on where a gameobject collides? 1 Answer