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
3
Question by klajntib · Mar 25, 2014 at 03:26 PM · mecanimlayeranimation events

Mecanim animation layers and animation events

I have a Base Layer and multiple other override layers with different animations.

Normally only the base layer is active and all the other layers have their weights set to 0.

Now I started putting animation events on the animations and I noticed that the events get triggered on every layer even if their weight is set to 0 and I get spammed by sound from every layer.

Is this the correct behavior of the layer system? And how do I prevent an inactive layer (weight==0) from triggering animation events?

Comment
Add comment · Show 1
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 Razouille · Apr 27, 2014 at 09:50 AM 0
Share

Did you find any solution ? I got the same problem, my temporary solution is to active a flag in the first function call and add a if condition at the start of this function, but it's quite unstable...

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by grasmann · Oct 20, 2015 at 12:01 PM

I have the same problem. What I came up with now is this extension:

 using UnityEngine;
 
 public static class Extensions {
 
     public static int GetDominantLayer(this Animator Animator) {
         int dominant_index = 0;
         float dominant_weight = 0f;
         float weight = 0f;
         for (int index = 0; index < Animator.layerCount; index++) {
             weight = Animator.GetLayerWeight(index);
             if (weight > dominant_weight) {
                 dominant_weight = weight;
                 dominant_index = index;
             }
         }
         return dominant_index;
     }
 
 }

Basically it returns the index of the layer with the highest weight. In my animation events I'm passing the layer index I want this event to happen on via the int parameter. In the function of the animation event I just have to check if the int parameter matches the dominant layer index.

 void MyEvent(AnimationEvent evt) {
     if (evt.animatorClipInfo.weight > 0.5 &&
     evt.intParameter == animator.GetDominantLayer()) {
         // Do stuff
     }
 }
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 meat5000 · Apr 27, 2014 at 10:48 AM

The animation 'ticker' will keep tracking through in order to help with animation syncing. You must make sure the exit parameters are properly set so the animation is not playing, just tracking.

It is simple enough to set the default state for each layer to be an Empty State and this will work with no errors or problems.

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 cpchristenson · Jul 03, 2014 at 09:05 PM 0
Share

What are these exit parameters you refer to?

avatar image
0

Answer by LaurynasLubys · Mar 26, 2016 at 04:04 PM

I have the same problem. Any other solutions to this ?

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

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

24 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 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

Animation events firing all at once in mirrored blend tree 1 Answer

Mecanim animation layers with a body mask kills the base animation? 1 Answer

How do you make additive animation blend correctly? 0 Answers

4.3, Animation Event in Animations from Mixamo 1 Answer

Mecanim & BodyMask 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