Search Unity

Animation Events not always firing

Discussion in 'Animation' started by Nikovich, Jan 20, 2015.

  1. Nikovich

    Nikovich

    Joined:
    Jul 10, 2010
    Posts:
    69
    I have a 2D character with four different idle animations. Each one is set not to loop and they are all frame based sprite animations. On the last frame of every animation is an event which calls a script that sets a random time for another random idle animation to play (I'd much rather set an animation end delegate with code but all my searches result in people saying set animation events). He plays a few animations like he's supposed to, but eventually, he stops firing the function on the animation event.

    I've read that a few people have experienced cases where events don't always fire. The only work around I've seen on those is that they put the event one frame before the end of the animation, but besides not being an optimal solution, it seems it only causes it to misfire less, and not fix it. Is this a known issue or is there something I'm not doing properly? I've only been using the animator to make 2D sprites with 4.6 for about a month now.
     
  2. Nikovich

    Nikovich

    Joined:
    Jul 10, 2010
    Posts:
    69
    I think I figured out the issue. If you don't specify the animation to play from the beginning, and it plays the same animation, the event won't fire. It can be fixed by simply including the playtime from 0; if you just tell the animation to play without specifying a time, the event seems to not play again.
     
  3. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    In 5.0 we did fix a few issue with animation event not firing correctly.
    Event at time 0 are the more problematic in 4.x, if you could log a bug with your project we will take a look.