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 webNeophyte · Dec 12, 2012 at 06:46 PM · animationmecanimadditive

Quick additive animations with Mecanim

I am trying to do a quick punching animation for my character using the new Mecanim system. I watched the video tutorial with the hand waving, but the wave animation is much slower and can blend better. There is an "override" option for the layer that you can set in the controller(instead of additive), but that doesn't seem to help. Is there something in the animation settings that will kill the transition between states and make the weight go straight to 1?

thanks for you help. Scott

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 webNeophyte · Dec 13, 2012 at 03:58 AM

I figured it out. The issue has to do with a layer property in mecanim called "weight". It controls the blending weight for the entire layer. When you create a layer in Mecanim, it defaults to 0 (no influence). You have to manually change it via script if you want it to play.

 animator.SetLayerWeight( 1, 1.0f );

"animator" is an instance of the Animator class that your character uses. It grabs the layer (first parameter) and sets the weight (second parameter).

http://docs.unity3d.com/Documentation/ScriptReference/Animator.SetLayerWeight.html

[1]: http://docs.unity3d.com/Documentation/ScriptReference/Animator.SetLayerWeight.html

Comment
Add comment · Show 5 · 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 coffiarts · Feb 19, 2013 at 02:59 PM 0
Share

Thanks for sorting this out!

In my case, however, the weight of a new layer always seems to default to 1 ins$$anonymous$$d of 0. Can you tell us the unity version with which you've tried this?

I only asking this because my additive animation layer in mecanim doesn't play at all (even with weight = 1), no matter what I do. So I am wondering whether the problem/solution decribed here matches my own problem.

Thanks alot!

avatar image webNeophyte · Feb 20, 2013 at 01:19 AM 0
Share

I am using some flavor of Unity 4.0. Can't remember the $$anonymous$$or version number at the time. Right now I am in 4.0.0f7.

For your problem, I would first check out the animation to make sure it imported correctly in Unity. For testing $$anonymous$$ecanim stuff, I usually keep the Animator window open to see which animation states are firing off when ( Windows > Animator). Also you could try setting the other layers to 0 weight to see if that makes a difference.

avatar image coffiarts · Feb 20, 2013 at 07:59 AM 0
Share

Thanks for your reply, webNeophyte!

I am using some flavor of Unity 4.0. Can't remember the $$anonymous$$or version number at the time. Right now I am in 4.0.0f7.

Alright, it's the same for me. So we're talking about the same version.

For your problem, I would first check out the animation to make sure it imported correctly in Unity. For testing $$anonymous$$ecanim stuff, I usually keep the Animator window open to see which animation states are firing off when ( Windows > Animator).

I guess that I've checked all of this, but I remember that the animation states in the animator preview window seem to be stuck somehow, which indicates that there might be something corrupt. Definitely worth checking this first.

Also you could try setting the other layers to 0 weight to see if that makes a difference.

That's a really good idea that didn't come to my $$anonymous$$d so far! Will try to have a look at this! Thx.

avatar image nielsvaes · Mar 16, 2013 at 01:23 PM 0
Share

I was struggling with the same problem. The weight in the Animator for my second layer was set to 1, but the animations never played.

I added

 animator.SetLayerWeight(1, 1);

in Start() and then it worked. So I'm guessing even though the Animator windows shows the weight is 1, it gets reset to 0 when you start your game.

avatar image coffiarts · Mar 16, 2013 at 02:44 PM 0
Share

Yes, I can also confirm this. I did it slightly differently, but with the same (positive) effect:

 animator.SetLayerWeight(0,0);
 animator.SetLayerWeight(1,1);

This makes both of my layers work perfectly. From what nielsvaes posted, I learned that I can omit my first line of code. And, of course, I also had to ensure that the same is applied to any other additional layer. Hence in my case (with one Base Layer and 4 extra layers) the working solution looks like this:

 //animator.SetLayerWeight(0,1); // unnecessary!
 animator.SetLayerWeight(1,1);
 animator.SetLayerWeight(2,1);
 animator.SetLayerWeight(3,1);
 animator.SetLayerWeight(4,1);


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

11 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

Related Questions

Mecanim additive animation sends characters flying? 1 Answer

Reference clip for Additive blending animation in Mecanim 0 Answers

How to combine mecanim and script based bone movement/animations? 2 Answers

Custom unity Animation wont work properly (adding avatar to animation?) 0 Answers

Animation Events and Mecanim 0 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