Search Unity

Animation Event can't work in low frame rate...Help.....

Discussion in 'Editor & General Support' started by iverson, Aug 24, 2010.

  1. iverson

    iverson

    Joined:
    Dec 27, 2008
    Posts:
    81
    i have added some event to the animation.As high frame rate it works well,but when the frame rate too low the event missed sometimes..
    who can help me to fix it
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    get your framerate to the point where it does not go through 2 frames in a single frame skipping yours totally. either that or play the animation slower ...
    what also helps is attempting to have a fixed framerate thats equal or multiplies of the animation framerate (lets say animation framerate of 30 and target FPS of 60)
     
  3. iverson

    iverson

    Joined:
    Dec 27, 2008
    Posts:
    81

    how could i fixed my framerate...i have no ideal how to control the framerate.
    as what you said,it skipped the frame of AnimationEvent and i can't prevent it? so,any other way to do with animation event?

    "either that or play the animation slower ..." do you mean that set the speed of the animation slow when it's low framerate ?
     
  4. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Sorry to dig an old thread, but is this sync problem resolved nowadays ?

    AnimationEvents could be an ultra powerful tool for many game features, but if it's synced with the fps, it's clearly not reliable.

    Isn't there some kind of security, checking the event to trigger based on time elpased since animation start ? That would solve the sync problem ...
     
    Last edited: Nov 10, 2010
  5. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Ok, I've tested AnimationEvents with a forced 10 FPS webplayer, and it worked perfectly.

    It's reliable.
     
  6. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    As far as I know animation events should be framerate independent. File a bug if they are not.
     
  7. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Thank you for your feedback.
    I suspect that some AnimationEvent are still not triggering correctly under highly stressed out performances, when both GPU and CPU are put to the ground.
    As it is not happening systematically, and under some heavy graphic/code loading, filing the whole project could unveil some confidential info.

    I'll make plenty of tests to isolate the function and check if it really comes from AnimationEvent, but if it is, how could I help without sending the whole project ?
     
    Last edited: Feb 15, 2011
  8. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    Then you should try to make a minimal project and just try to create a heavy load in it somehow (just doing a lot of matrix multiplications could work, or maybe plain delays could reduce framerate too). We really need (and appreciate) good bug reports, otherwise everyone's time gets waisted.
     
  9. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Ok, I'll provide a useful file as soon as possible, thanks.
     
  10. Lypheus

    Lypheus

    Joined:
    Apr 16, 2010
    Posts:
    664
    I'm seeing this as well, Unity 3.3.0f (63049) build.

    I had noticed that my game seemed to "hang" sometimes but found it was from errant animation events (I drop the character and play a "landing" animation at start, which in turn calls a OnLandEnd() method to release control to the user).

    Also noticed this today while using my internal video card on my M17x (don't buy one, ever) - added some additional logging and confirmed this, VERY sporadic and tough to reproduce.

    Anyhow, thinking i'll avoid using animation events as the only means of exiting code - which is a real shame since it would be a very elegant way of handling state changes for my code. I'll probably get the clip duration and use as an offset to the current time as a guard condition (hard cutoff) for forcing an OnLandEnd() call if not already called.
     
  11. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    this issue seems to stil be hiding somewhere for us to on 3.4.1 :-(
    we've tracked down one cause for this random occurrence, being that multiple instantiations of a GameObject housing the AnimClip the event-placement-code houses are adding the same animEvent each time another GameObject of that type is instantiated.
     
  12. abhishekm942

    abhishekm942

    Joined:
    Oct 18, 2019
    Posts:
    10
    As a workaround tht I tried, copying the keyframes of the final frame and pasting them in either side of the final frame helps. When ever the game running at low fps skips the final frame, it means that one of the frames near the final frame is rendered but not the final frame. If we copy and paste the keyframe in the above manner the final frame will apparently be rendered (or any of the adjacent frames where we copied the keyframes).
     
  13. ColdJackle

    ColdJackle

    Joined:
    Apr 29, 2016
    Posts:
    5
    To further dig up a very old thread and to help anyone with similar problems as @abhishekm942: In the case of the event being at/in the final frame, be aware of your transitions. By default they come with a non-zero transition and exit time. If you happen to have low FPS or a missconfigured transaction, the last frame(s) can sometimes not actually be rendered/called. This is not dependend on low FPS alone. An event in the middle of an animation will work just fine with low FPS. But a transition can acutally skip some frames and that seems to apply to events aswell. I had this "bug" (it's not a bug, it's indeed a feature, no sarcasm) a few weeks ago in Unity 2020.1.6f1, and was able to resolve it completely by setting my exit transition to be 0 frames long. In my case I actually needed a zero time transition, but a better approach would be to just use State Machine scripts for events at the end of an animation.

    TLDR: Events and Animation Transitions don't play well together. Use State Machine scripts if you encounter to many problems with that.
     
  14. scorp2007

    scorp2007

    Joined:
    Aug 17, 2014
    Posts:
    54
    none of the above solutions worked, if I put 10 fps by force - the animation event almost never fires ...
     
    Matvey_Poletin likes this.
  15. PasMol

    PasMol

    Joined:
    Feb 5, 2016
    Posts:
    13
    Has this bug been fixed?
    I wanted to add events, but I thought that due to the fast FPS, some frames would be skipped. I decided to clarify this on the Internet and ended up here.
    Is this still happening in the latest versions 2021-2023?
     
  16. juaojones

    juaojones

    Joined:
    Oct 5, 2020
    Posts:
    2
    Late 2023 here and it still happens... My falling animation doesnt trasition to land/running on low FPS.
     
    PasMol likes this.