Search Unity

Mecanim animation events inconsistent - framerate dependent?

Discussion in 'Animation' started by boromir6, Nov 17, 2015.

  1. boromir6

    boromir6

    Joined:
    Feb 23, 2015
    Posts:
    21
    I'm having a very frustruating issue with mecanim in version 5.1.1. I have a few events on a character timeline for player attack, for setting hitboxes, sounds, etc. After noticing some odd behavior with events not always firing, I decided to do some tests. I assumed it was a code issue because it appeared that only the last event refused to fire, but now I'm really not so sure. It explains other quirks like hitboxes sometimes staying when they are supposed to be disabled halfway through the animation. I did some rough "tests" to try to get to the bottom of this

    the last event misses rarely at 60 fps, often at 30 fps, and almost always at 10 fps.

    Changing timescale has interesting effects. at lower timescales, the animation sometimes "freezes" at the end. At higher timescales, the last animation event is almost always missed.

    setting the starting keyframe to -1 seems to exacerbate the issue(maybe?)

    I was unable to test the "middle" events, but it would explain wonky hitboxes. I'll probably do some logging later.

    I really hope this is user error, because I assumed mecanim had checks like this in place, verifying elapsed time or something, 30 fps isn't unreasonable for target specs, and I might just have to re-write to be independent of mecanim.

    Any insight is greatly appreciated.

    EDIT: it appears events aren't being missed, after comparing the results of each number of times functions were called, they were all equal. My guess is that the animation sometimes transitions on the same frame the event is fired, resulting in a "missed" result before it can be compared. It doesn't explain the freezes or hitboxes but that's for another day I guess. Sorry to bother y'all.
     
    Last edited: Nov 17, 2015