Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Animation event not triggering

Discussion in 'Animation' started by Happy_Jingle, Feb 13, 2017.

  1. Happy_Jingle

    Happy_Jingle

    Joined:
    Mar 9, 2014
    Posts:
    102
    Currently in my game a lot of events are triggered from within an animation and occasionally they seem to be skipped over. It's imperative that an event never get skipped, how do I make sure this doesn't happen?
    Here are the settings on all my animations:
    Example of how events are placed:
     
    quantumhop likes this.
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,773
  3. Happy_Jingle

    Happy_Jingle

    Joined:
    Mar 9, 2014
    Posts:
    102
    The answers on a lot of the threads I've gone through are quite old, I was hoping there was updated information. Furthermore they aren't actually "answers" more like "this is broken don't use it" so I was hoping to find an actual answer.
     
    Deeeds and quantumhop like this.
  4. omegabytestudio

    omegabytestudio

    Joined:
    Nov 9, 2015
    Posts:
    72
    @Happy_Jingle

    I feel you man.

    I might be able to help you, not sure if it's the same issue.

    I had trouble when I tried to call an event on a frame, and that frame was occuring during a transition to another animation.

    Like If I was punching, and mid animation I would kick, the last frame wouldn't call the event.

    Could it be your issue too?

    To resolve this issue, I'm using a way that might not be the best, but it works for me.

    I have both event on the animator and state machine behavior with the same event call on the OnStateExit fonction.

    Why both?

    Event : Sometime won't call on transition.

    State Machine Behavior : Won't call OnStateExit if the animation loop, and it was looping for me. If you aren't looping, you can only use State Machine Behavior.

    I hope it helps you!
     
  5. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,574
    Please log a bug if there is something that doesn't work as expected.
    We do have over 50 different test for animation events that are run everytime we do build unity that cover many edge case.

    If there is some case that still doesn't work we would like to know
     
  6. omegabytestudio

    omegabytestudio

    Joined:
    Nov 9, 2015
    Posts:
    72
    Does the situation I describe is a bug? I just thought it was how it was supose to work?
     
  7. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,574
    If you expect that your animation events should be fired but it not fired then yes log a bug, we will do the investigation and if we found out that it broken we gonna fix it, if it not broken we will give you an explanation why we think it work as expected.

    So yes log a bug
     
    theANMATOR2b likes this.
  8. Ylisar

    Ylisar

    Joined:
    Jan 27, 2014
    Posts:
    6
    Where is the documentation for animation events with mecanim? I can only seem to find the docs for animation events when using the legacy system. For example, how does events work during a transition? Some googling seems to suggest they're broken with mecanim, but those are mostly old posts.
     
    Deeeds likes this.
  9. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,574
    There is nothing specific to mecanim or legacy, basically if a clip is currently playing it should trigger events.

    A transition is essentially a cross fade between 2 animation clip, so as long as both clip are played they should both trigger animation events.

    There is no know issue with animation events at the moment in 2017.1 and on newer version so I would expect them to work reliably
     
    Ylisar likes this.
  10. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    277
    Last frames on animations are definently skipped at times. Especially during a transition to another anim. Giving me headaches
     
    Deeeds likes this.
  11. Mijail_Bitboys

    Mijail_Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    144
    Any news about how to solve this?
    For me it is impossible to use animation events because sometimes they work and sometimes they do not.
    I just want to send a message to another script when the animation reaches a certain frame but it does not work exactly. It's a simple trigger animation.
     
    Deeeds likes this.
  12. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,574
    Please log a bug, there is currently no know issue about animation events not firing for the animator component
     
  13. ed7k

    ed7k

    Joined:
    Jul 4, 2016
    Posts:
    1
    Deeeds and theANMATOR2b like this.
  14. SergioMartinPulido

    SergioMartinPulido

    Joined:
    Mar 19, 2018
    Posts:
    1
    Hello I am having the same problem. I will introduce my case:
    I am using Animation Events to trigger sounds at a specific frame. For some reasons the events placed at the first key frame are only triggered the first time I play the animation. The next times I try to play the animation the Animation Event is skipped. I am using Simple Animation Component to trigger the animations not Mecanim. (So we are not using transition blending or exit time)

    https://blogs.unity3d.com/es/2017/11/28/introducing-the-simple-animation-component/

    In theory uses Playables to play the animations.
    My unity version is 2017.3.1f1

    Any help will be very usefull

    Regards

    trunk (Ejecución) - Microsoft Visual Studio .jpg
    PrtScr capture_3.jpg

    Animation event not triggering  Unity Community - Google Chrome.jpg
     
    Deeeds likes this.
  15. willianbrasil

    willianbrasil

    Joined:
    Oct 17, 2017
    Posts:
    5
    Hi i've worked on three different projects with Unity and i've always had problems with animation events at the end of animation because they seem to fire whenever they want to, to solve this i've come up with two methods:

    1: Put a phantom frame at the end of the animation, after the event frame, and example of phantom frame is a GameObject property which will be enabled/disabled according to your current animation so it won't change anything.

    2: Get the animation length which you desire to activate the event and at the end of the desired animation activate the event.

    Obs: I've never used state machine behaviours, so it might be a good alternative.