• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by AtticusMarkane · Jul 22, 2015 at 04:55 AM · mecanim

Why is mecanim Animation Event not Firing when on last frame?

This is one of my biggest frustrations with Mecanim. If you place an animation event on the last frame of an animation it seems as though there is no guarantee that it will be called. I have set the Exit time to 1 and the transition duration to 0 in order to mitigate the issue of the transition interfering with the event but I still have the issue.

I have attached a screen shot of the animation with the event and the transition info. If anyone can tell me what I am doing wrong it would be much appreciated. alt text

mecanimanimproblem.png (134.1 kB)
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lardratboy · Jul 26, 2015 at 05:53 PM 0
Share

I recently discovered State$$anonymous$$achineBehavior specifically OnStateExit which seems to be a reliable way to watch for the end of an animation state.

http://docs.unity3d.com/ScriptReference/State$$anonymous$$achineBehaviour.OnStateExit.html

Please post any solution you find or an explanation to why/how to get the last keyframe animation event to work I would really like to understand...

avatar image Eluem · Nov 05, 2015 at 09:42 PM 0
Share

Since it seems like animation events are skipped when frames are skipped and everyone dislikes this, please take the time to vote on this suggestion to add a feature which will allow us to choose to make our animation events guaranteed:

https://feedback.unity3d.com/suggestions/animation-event-guarantee

1 Reply

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by AtticusMarkane · Nov 06, 2015 at 04:41 PM

So I discovered what I was doing wrong.

When using an event on the last frame two things need to be done:

  1. Make sure that your transition in Mecanim does not occur until the entire animation has finished playing

  2. Make sure your animation does not have "loop time" enabled. This appears to occasionally skip the final frame.

Do these two things and you should be in business!

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eluem · Nov 13, 2016 at 09:00 PM 0
Share

This used to work.

However, at least as of version 5.4.2f2, I'm finding that this solution no longer works.

Animations Events that I had set up to rely on this have stopped working after upgrading from version 5.3.5p1.

If anyone knows if there's any patches I should look into or if there was any documentation posted about a good reason for this change, please let me know.

Thank you.

avatar image AtticusMarkane Eluem · Nov 13, 2016 at 09:40 PM 0
Share

I haven't noticed any issue with this but to be fare I have not been doing a lot of $$anonymous$$ecanim work lately. I'm not sure if it helps but have you tried looking into the State$$anonymous$$achineBehaviour class? https://docs.unity3d.com/ScriptReference/State$$anonymous$$achineBehaviour.html

It allows you to monitor for changes in the $$anonymous$$ecanim state machine and run code based on them. Its not exactly a fix, but it may help you do what you are trying to do now.

avatar image Eluem AtticusMarkane · Nov 13, 2016 at 10:10 PM 0
Share

Apparently it's a bug in the latest version. I found an issue here: 843714

I'm trying to figure out if there's any patched versions that fix this. I haven't been able to find one yet.

avatar image Cherno · Nov 13, 2016 at 09:27 PM 1
Share

I noticed this issue as well and I just "solved" it by putting the Event one frame before the last one.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get current state on Mecanim? 4 Answers

Mecanim curve for move speed 0 Answers

Mecanim: BindSkeleton: Cannot find transform 2 Answers

How can I tell what AnimationState mecanim Animator is in from script? 1 Answer

Mecanim For Android! 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges