Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by dchen05 · Jan 11, 2013 at 01:56 AM · animationtriggermecanim

Mecanim Trigger event on specific frame of an animation

Without using collision detection, is there a way I can define a "hit" frame within an animation package that can be read by Unity to trigger an event?

I'm using a mecanim generic skeleton and doing the animations in Maya.

Comment
Add comment
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

4 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by JesseBusch@IL · Mar 15, 2013 at 07:57 PM

While this may not let you get an event to occur on an exact frame of an animation, here is a trick I've been using to get a semblance of animation events out of Mecanim.

In Mecanim, you can add data curves to animations that will allow you to pull values from the animation system while its running. (To find out how to work with curves, check out this section of the Mecanim video tutorial

So, for example, let's say we have a boy who needs to throw a ball. WIth the techniques described in the video, I could add a curve to his throw animation. That curve would start and end the animation at 0, but about the time the boy needs to release the ball, I would make the curve spike up to above a value of 1.

You can then have a script watch and pull this float value from the animator, and if it detects the int value has gone above 1, it can do what it needs to do to populate the ball or do a hit or whatever event you need it to perform. You'll, of course, need to flush out the code a little bit so that the event only happens once during a single animation, but this should at least help you get going in the right direction.

Comment
Add comment · Show 1 · 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 dchen05 · Mar 15, 2013 at 08:35 PM 0
Share

Cool thanks, will this stay with the animation when its speed is modified in the Animator Controller ? Also just a mention to everyone else looking at this that Curves seems to be a Pro Only feature.

avatar image
-1

Answer by G1NurX · Mar 15, 2013 at 04:26 PM

https://www.assetstore.unity3d.com/#/content/5969 I think this tool meet your need.

Comment
Add comment · Show 1 · 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 dchen05 · Mar 15, 2013 at 08:35 PM 0
Share

Cool thanks!

avatar image
-1

Answer by HowBoring · May 13, 2014 at 07:20 AM

https://www.assetstore.unity3d.com/#/content/16357 This tool might be better. Just check it out.

Comment
Add comment · 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
0

Answer by Jason_DB · Jan 11, 2013 at 03:35 AM

I'm not overly familiar with mecanim so I can't be sure if this still applies, I think that this could be done with animation events, which allow you to call a function when a specific animation frame is played.

*Also, if Unity doesn't let you edit the animation, try making a duplicate of it - you can't edit animations directly in the imported file, but duplicating it creates an editable animation file.

Comment
Add comment · Show 3 · 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 dchen05 · Jan 11, 2013 at 03:56 AM 0
Share

Hey thanks for the reply, I looked into it and it looks like that solution won't work with mecanim :(

http://forum.unity3d.com/threads/156492-$$anonymous$$ecanim-and-Animation-Event

It seems like this is pretty crucial feature that they overlooked. I think I might try to do something in $$anonymous$$aya that I could then listen for in Unity. We'll see how it goes.

avatar image Jason_DB · Jan 11, 2013 at 04:06 AM 0
Share

That's very unfortunate - animation events are really useful in a lot of different situations. If you can still access animation states in mecanim (http://docs.unity3d.com/Documentation/ScriptReference/AnimationState.html), you might be able to check the 'time' of the animation as an approximation for the frame.

avatar image dchen05 · Jan 11, 2013 at 04:51 AM 0
Share

Thanks,

I believe "AnimationState.normalizedTime" would be sufficient http://docs.unity3d.com/Documentation/ScriptReference/AnimationState-normalizedTime.html

However, I'm pretty sure I can't use that with $$anonymous$$ecanim as all the available options are listed here in the Animator class. I hope im wrong on this and someone can correct me. http://docs.unity3d.com/Documentation/ScriptReference/Animator.html

Thanks for the help, but if this is the case its pretty bad on Unity's part...

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.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why isn't my animation being played? 0 Answers

Mecanim animation events not working properly 0 Answers

on trigger enter - play mecanim animation 0 Answers

Clear mecanim trigger input? 1 Answer

Mecanim Trigger Stays too long true 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