Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Animation Event firing but visual state is still not there?

Discussion in 'Animation' started by chilledbits, Jan 24, 2022.

  1. chilledbits

    chilledbits

    Joined:
    Jan 4, 2018
    Posts:
    17
    Hey guys I would be glad if someone could explain this for me.

    I have an Animation triggered by an Animator. In the last frame I have an Animation-Event.
    OnAnimationFinished
    In the OnAnimationFinished Callback I disable the Animator-Component.

    Expected behavior:
    I see the last frame of the animation, and the animator is disabled.

    Current behavior:
    Sometimes (performance-dependent) I see a frame which is before(!) the last one, but the Animator-Component is disabled.

    Question:
    Why is the Event firing while the visual state is not yet there and/or is there a possibility to enforce the rendering of the last frame?


    Just for explanation: I have quite a lot of GameObjects which only have one Animation. This Animation is only played once or even never. That's why I would like to deactivate the Animator for performance-reasons.
     
    Last edited: Feb 7, 2022
  2. unity_2cdeity

    unity_2cdeity

    Joined:
    Dec 19, 2020
    Posts:
    17
    I cant tell you anything about why but from what I understand you want a time based method? wouldnt it be better to just cashe the time of the animation in the object and disable it?
     
  3. chilledbits

    chilledbits

    Joined:
    Jan 4, 2018
    Posts:
    17
    Thank you for your response - unfortunately I don't know what you mean with caching the time of the animation - could you explain that a bit more?

    To clarify maybe a bit more:
    I don't really need something "time-based". The only thing I'd like to achieve is to disable the Animator-Component after the last frame was properly displayed.