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 Iskander · Jul 29, 2014 at 12:04 PM · animationmecanimlayersblinking

Adding an eyeblink animation layer

Hi!

I have a character with some animations set up in Unity. Now I wanted to have another animation clip with random eyeblinks playing on top of the other animations. It is just a looping clip of about 300 frames.

I put this animation inside a new animation layer and set it to additive mode, it works well. But there is one animation clip in the Base layer where I don't want the blinks to show up.

How can I exclude this animation clip from the 'eye blink' layer so that the eyes won't blink when this certain clip is played?

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 Iskander · Jul 29, 2014 at 04:44 PM 0
Share

I have made some screenshots to clarify my problem a bit:

So I want the eyeblink animation to loop continuously and keep adding eyeblinks to every animation clip in the base layer EXCEPT the one called 'Alien_LookUp_Smile_LookDown', because it already has specific face animation on it.

I wanted the eyeblinks on a different additive layer so that they would be more random and not dependent on the ti$$anonymous$$g of the other clips. This works fine, only I can't control on which clip the eyeblinks will be added or not.

$$anonymous$$aybe I'm approaching this the wrong way? Any help is welcome.

alt text

alt text

base layer.png (25.6 kB)
eye blinks.png (22.3 kB)

1 Reply

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

Answer by superpig · Jul 29, 2014 at 05:02 PM

The simplest way to do this is probably to just set things up so that the Weight of the eyeblinks layer gets brought to zero for the duration of the animation.

You could do this by simply changing the layer weight at the same time you set things to trigger the Alien animation to play, and then changing it again when you trigger progression to the next animation.

Alternatively, perhaps you could use Animation Events on the Alien animation to fire 'StopEyeBlinks' and 'StartEyeBlinks' events.

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 Iskander · Jul 30, 2014 at 03:38 PM 0
Share

Thanks for the answer, superpig, it works for me. This is the code I put together if someone is wondering:

 // Create an animator variable
     private Animator anim;
 
     void Start () 
     {
         //Grab the Animator component from the character
         anim = GetComponent<Animator>();
     }
     
     // Update is called once per frame
     void Update ()
     {
         //Eyeblinking/////////////////////////////////////////////////
         //Here we say when the Eyeblink animation should play or not//
         //////////////////////////////////////////////////////////////
 
         //check if animation lookUp has started.
         //the (0) points to the Base Layer index, which contains the animation we want
         if (anim.GetCurrentAnimatorStateInfo(0).IsName("Alien_LookUp_Smile_LookDown"))
         {
             //change the Eyeblink layer weight to 0, so no eyeblinks
             //the first number stands for the layer index, so Base Layer = 0, Eyeblink Layer = 1
             anim.SetLayerWeight(1,0);
         }
 
         else
         {
             //change the Eyeblink layer weight to 1
             anim.SetLayerWeight(1,1);
         }
     }


The only thing it doesn't do is respect the transition to blend with the previous animation, which can sometimes still cause a bad eye deformation (2 eyeblinks on top of each other) when the transition blend hasn't finished yet and the Blink layer weight has already changed to 1.

But for now it's a good solution, thanks!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Possible to use different rig on layer mask? 0 Answers

Animation layers with Unity 2D mecanim 0 Answers

How to superimpose two animations using the animator? 0 Answers

Mecanim layers blending 0 Answers

Mecanim avatar masks don't work. 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