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 paco morales · Dec 21, 2012 at 07:03 AM · animationslayerblend

I want to blend two animations

Hello,

I have problems blending two animations, I want to start the animations to the same time. I tried to use AnimationState.layer but I don't know why is not working my script.

I want to blend (Key and ShaftLockButton) animations.

Any advice.

Thanks in advance for your help.

 var Skin_tool: GUISkin ;
 var Skin_battery: GUISkin ;
 var Skin_key: GUISkin ;
 var Skin_power: GUISkin;
 var beep : AudioClip;
 var other : GameObject;
  
 function OnGUI (){
 
 //Make the OnOffSwitch button
     GUI.skin = Skin_power;
     if (GUI.Button(Rect(770,227,80,52),"")){
      audio.PlayOneShot(beep);
      animation.PlayQueued ("OnOffSwitch");
      }
      
     //Make the ShaftLockButton button
     GUI.skin = Skin_lock;
     if (GUI.Button(Rect(770,282,80,56),"")){
      audio.PlayOneShot(beep);
      animation.PlayQueued ("ShaftLockButton");
     }     
     
     //Make the Tool button
     GUI.skin = Skin_tool;
     if (GUI.Button(Rect(770,341,80,68),"")){
      audio.PlayOneShot(beep);
      animation.PlayQueued ("Tool");
     }
     
     //Make the Key button
     GUI.skin = Skin_key;
     if (GUI.Button(Rect(770,412,80,35),"")){
      audio.PlayOneShot(beep);
      animation["Key"].layer = 1;
     animation["ShaftLockButton"].layer = 1;
     animation.SyncLayer(1);
           
     }
          
     //Make the Battery button
     GUI.skin = Skin_battery;
     if (GUI.Button(Rect(770,450,80,38),"")){
     audio.PlayOneShot(beep);
     animation.PlayQueued ("Battery");
     }    
         
 }
  
 @script RequireComponent(AudioSource)
  

  
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 paco morales · Dec 25, 2012 at 11:52 PM 0
Share

Thanks for your help!

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Owen-Reynolds · Dec 21, 2012 at 04:40 PM

Blending is like averaging -- add them up and divide by 2. For animations, play them both at 1/2 weight, and the system will add them together.

So, somewhere you should have animation["key"].weight=0.5;

The animation system wants to play 1 animation per layer. To blend two, but them on different layers, and set the one on the highest layer to weight 0.5. The system will automatically give the other one the remaining 0.5.

SynchLayer, which you have now, changes them both to be the same length. If they are the same length, it does nothing. If they are on different layers, you can synch yourself by just comparing times. If KEY takes 1 sec and SHAFTLOCK takes 1.5 secs, set the speed of SHAFTLOCK to 0.6666. Now it also take 1 sec (this is all SynchLayer does -- set speeds.)

If you want to keep them on the same layer, you can't use animation.Play commands. They are set to quit other animations on the same layer. A trick is to use animation.enabled=true, instead of Play.

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

10 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

Related Questions

A node in a childnode? 1 Answer

How to mix animations? 3 Answers

Moving an object on elliptical path 1 Answer

How to setup animtion????? 2 Answers

Problem with multiple animation Controlle Script 2 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