Search Unity

Animation events not working

Discussion in 'Animation' started by iSinner, Mar 11, 2015.

  1. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    So i encountered a problem with animation events, since Unity 5, the animation events do not trigger if they are on the first frame of animation. Does anybody have the same problem? and if anyone knows a solution, please share.
    And by animation events, i mean these ones
     
  2. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
  3. fishg

    fishg

    Joined:
    Jul 25, 2014
    Posts:
    90
    This also happened on put a event on last empty frame.
     
  4. Mish

    Mish

    Joined:
    Apr 23, 2010
    Posts:
    96
    I also get this issue, but seems it doesnt always occur. Sometimes if exit time is not enabled it wont skip the event.
     
  5. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    Please upvote the issue on issue tracker (link above, 2nd post) if you have the same problem and would like to get it fixed asap.
     
  6. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Your case is a special case where there is no animation at all and only one event at time 0.
    This bug has been fixed and should be available in an upcomming patch release.

    If you have other case please submit a bug report with your project.
     
  7. mchts

    mchts

    Joined:
    Dec 28, 2015
    Posts:
    8
    If you crossfade between animation clips then first few keys may be skipped because of fade process. You should use Play() to be sure in this case.
     
  8. FiveFans

    FiveFans

    Joined:
    Oct 21, 2015
    Posts:
    10
    I know this thread is a little dated. I'm providing this in case it helps others. I was having a similar problem. I had an event that was to be called at the end of my (non looping) animation. It would play the first time but that's all. My animation event a stand alone animation (there were no transitions to other animations).

    What fixed it for me to create a new "idle" animation. Once I created this (useless) idle animation I made a transition from my animation to the idle animation. I didn't have any triggers, just an exit time of 1.0 with no cross fading. Once I did this, my end of animation event I added was called correctly. Strangely I thought the event would work as a stand alone animation but it was only called the first time.

    My use case was for a player running animation (player_run). I wanted to know when it finished (finished_running) and determine if the player's velocity was over a certain speed it would call the player_run animation again. It worked correctly, the first time and player_run would be called once from finished_running but after that it wouldn't be called again. Once I used the above fix, it worked!