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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Brenden-Frank · Nov 06, 2012 at 06:37 PM · animationsoundeventblendingweight

Animation events play for all animations when blending?

I'm playing 3 animations:

             //Prioritize the walking animation
             anim["idle"].layer = 9;
             anim["walk"].layer = 10;
             anim["sprint"].layer = 11;
             
             //Play all animations
             anim.Play("idle");
             anim.Play("walk");
             anim.Play("sprint");
             
              //Fade out moving animations
             anim.Blend("walk", 0, 0.2F);
             anim.Blend("sprint", 0, 0.1F);

I blend walk and spring based on the character's forward velocity.

             //
             // In Fixed Update
             //
             if (velocity.sqrMagnitude <= sleepVelocity*sleepVelocity)
             {
                 anim.Blend("idle",1,0.2F);
                 anim.Blend("walk", 0, 0.2F); //Fade out walking animation
                 anim.Blend("sprint", 0, 0.1F);
             }
             else if(velocity.sqrMagnitude > sleepVelocity*25)
             {
                 //Fade in sprint animation
                 anim.Blend("sprint",1,0.2F);
                 anim.Blend("walk",0,0.2F);
                 anim.Blend("idle",0,0.2F);
             
                 anim["sprint"].speed = 1*animationSpeed;    
             }
             else
             {
                 //Fade in walking animation
                 anim.Blend("walk",1,0.2F);
                 anim.Blend("sprint",0,0.2F);
                 anim.Blend("idle",0,0.2F);
             
                 float animspeed = velocity.sqrMagnitude;
                 anim["walk"].speed = animspeed*animationSpeed;
             }

I have events on walk and sprint that generate footstep sounds. However, I often hear events from both animations playing rather than just the heaviest weighted one. How would one deal with an issue like this?

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

1 Reply

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

Answer by Brenden-Frank · Nov 08, 2012 at 06:05 PM

I ended up using anim.Crossfade() instead. It's a little less control but at least it isolates events.

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

9 People are following this question.

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

Related Questions

Play 2 animations at once 4 Answers

Play sound on animation event? 3 Answers

Doubled Animation Events In Blend Tree 1 Answer

how do u add sound clips to an animation using animation events? 1 Answer

Can't select function in Animation Event 9 Answers


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