Search Unity

Animation Events not calling their Methods - Is this still an issue?

Discussion in 'Animation' started by Tset_Tsyung, Jul 20, 2018.

  1. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    Hey all,
    MixamoEvent.PNG
    TLDR;
    I have a clip from Mixamo, it runs fine and is blended. But I need it to fire an event at the end so that I can run logic on the combo that the player made.

    Problem is that the Event is rarely called. I moved away from the end of the clip but this didn't solve it...

    Should I post another bug report on this (there are loads already)?
    Has anyone found an effective workaround?


    Further Explanation;
    Okay, so I've putting together a basic combo system with a max of 3 moves. The problem is that I want to know when the combo is finished.

    I'm trying to run 2 events. 1 when each combat clip is started, and one at the end of each clip. This is allowing me to track which moves from the combo have been completed. The problem is that the ExitedMoveClip function is rarely called!

    According to @Mecanim-Dev this shouldn't happen.
    (https://forum.unity.com/threads/animation-event-not-triggering.456138/)

    I tried searching the bug tracker but there were many bugs listed to do with animation events not being called. Should I post YET ANOTHER ONE about this issue?

    Are there any effective workaround that anyone's found out that works?

    I was thinking of simply creating a timer that has the time of each clip added to it to see when we've left the combo, but this feels clunky to me... thoughts?

    As always, you're all legends and I appreciate you looking at this post.

    Mike

    P.S. StateMachine behaviour seems to be random as to when it fires off the callbacks, so I've moved away from that idea for now...
     
    K1kk0z90_Unity likes this.
  2. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    Just an update.

    I have noticed that an event that's placed at the beginning of the clips WILL be called successfully (So far without fail), so it only seems to be events towards the end of the clips that have issues.

    So each time I have an attack animation playing I update a timer with the length of that clip. Once the timer runs out can evaluate the results.

    The good things is that in a combo of moves each animation is started before the previous ends. So the timer is being updated with the start of the new animation BEFORE THE OLD ONE finishes. So far this is working perfectly for my needs.

    Hopefully someone will be able to provide a more robust solution. But in the meantime I've posted this info so that someone else can learn from my (pathetic and noobish) efforts.

    Laters all.

    Mike
     
  3. MassimoFrancesco

    MassimoFrancesco

    Joined:
    Jul 6, 2019
    Posts:
    44
    Wow. I was about to go mad after hours of troubleshooting, because I have the same issue in 2020.2.0b. Animation clip event around half of play time fires correctly, while an animation clip event at ~ 80% runtime never fired his.

    This is the only thread I've found via search which has the workaround at hand. When I moved the 85% event a bit more to the left, around 55%, it calls the method correctly again.

    It still works for that specific animation, but I still need animation clip events towards the end.

    What I noticed, I had no issues with "at-the-end" event with an animation clip I created on my own in Umotion.
    While this issue only appeared since I swapped it out with a Mixamo animation, which I edited in Umotion Pro and added an animation clip event around the same ~80% mark at the end.

    I really wanna know what is triggering this faulty behavior. If I find out, I will post it here.
    In case someone has more information, please feel free to share!
     
  4. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    Seriously? No way! I was researching the bug Tracker the other day as I was wondering if this was still an issue (not needed to use animations event much...), the bug tracker says this was resolved.

    Does this problem still occur on the non-beta releases?
     
  5. unity_4XWcnhMEUZ043g

    unity_4XWcnhMEUZ043g

    Joined:
    Aug 27, 2020
    Posts:
    4
    Yep, i still get error, my event that is at the end of animation, does not fire.
     
  6. MassimoFrancesco

    MassimoFrancesco

    Joined:
    Jul 6, 2019
    Posts:
    44
    I researched this topic more after my last post and what I concluded was, that this doesn't seem to be a bug but rather intended behavior.

    As soon as an animation fades out to 0, due to animation blending, any later set animation events will not fire.
    Theoretically it must and should still fire, even if it is only at ~1% blending left.

    Depending on your game, it can still look like the animation should have fired its event near the end, while it in fact already blended out completely.

    So there is not much you can do at first, if you really want to have a callback near or at the end of a animation, even if it has faded out.
    Afaik, adding "Behaviour" scripts to your Motion, inside the Animator window, which do have state-machine-like "OnEnter" / "OnExit" methods being called.
    Or using some workaround logic in your main script, as Coroutines for the duration of the specific animation.

    I'd really love it if we had just an option on the AnimationEvent, some tickbox in the sense of "fire even when faded out".
     
    BRL0 likes this.
  7. omerselman

    omerselman

    Joined:
    Mar 5, 2016
    Posts:
    20