- Home /
Animation event fires three times on the first frame - is this a known issue?
Howdy, I have an animation with an event on the second frame and one on the last frame. The function that the events trigger takes an AnimationEvent as a parameter and prints the time that the event is triggered.
Triggering the animation gives this result:
which is exactly what I would expect.
What I really want is to have the first event to be on the first frame, but when I move that event onto the first frame (so there is just one event on the first frame and one on the last) I get this result:
As you can see, the function is triggered 4 times. Twice at the beginning, once at the end, and once at the beginning again. I'm not doing anything different other than moving the event between the second and first frames and the animation plays normally both times.
Has anyone had the same problem?
The function just looks like this:
function PrintTime(animEvent : AnimationEvent)
{
print(animEvent.time);
}
Thanks very much,
Romano
edit: I'm using Unity 4.5 and haven't tried using animation events before this.
Same issue, here. Works fine in the second frame, but if you move to the first one, it is fired 3 times.
i have the same problem. the event placed on frame 1 gets called twice, when i move the even to the second frame it gets called once. i think its a bug? if the event function i set on frame 1 is a toggle (if true set false if false set true), then because its called twice, it remains the same state which causes massive problem. i hope this gets fixed soon.
Answer by smoggach · Aug 11, 2014 at 04:40 PM
If your animation is on the default state of your animator it will play when it wakes up. Set your default state to one without an anim on it. The default state is the orange one.
A good point. I think it's unrelated to this issue though.
Your answer
![](https://koobas.hobune.stream/wayback/20220613150959im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
multiple enemies does nt work with this script but a a single enemy works..Please help 0 Answers
GetComponent in Multiple Children 1 Answer
how to cancel OnTriggerExit when already hitting a 2nd trigger 2 Answers
OnTrigger events on multiple objects 1 Answer
'PlayerBlue' AnimationEvent 'InAction' has no receiver! Are you missing a component? 1 Answer