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 Pivotblimp12 · Aug 03, 2012 at 12:14 PM · animationblending

Animation Blending Problem

I know this question has probably answered a million times, but I need a personalized answer if you don't mind :). What I'm trying to do is blend Walk right, walk left, walk forward, etc... All together seamlessly, and of course idle. Right now I'm dealing with CrossFades which doesn't seem to work very well. Im hoping you guys know of a better way to blend animations together. Here is my current code:

     function Update () {
 
 if(Input.GetKeyDown("w") || Input.GetKeyDown("s")){
 
 animation.CrossFade("Walk Forward",0.1);
 }
 
 if(Input.GetKeyUp("w") || Input.GetKeyUp("s")){
 
 animation.CrossFade("Idle",0.2);
 }
 
 if(Input.GetKeyDown("a")){
 
 animation.CrossFade("Walk Left",0.1);
 }
 
 if(Input.GetKeyUp("a")){
 
 animation.CrossFade("Idle",0.2);
 }
 
 if(Input.GetKeyDown("d")){
 
 animation.CrossFade("Walk Right",0.1);
 }
 
 if(Input.GetKeyUp("d")){
 
 animation.CrossFade("Idle",0.2);
 }
 

}

Comment
Add comment · Show 3
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 Owen-Reynolds · Aug 03, 2012 at 04:00 PM 0
Share

You say it doesn't work "very well." So it kind of works but is glitchy? What's wrong with it?

The usual CrossFade time is 0.3 seconds (if you don't even use a second number) -- 0.1 might be a little "snappy."

avatar image Pivotblimp12 · Aug 03, 2012 at 06:51 PM 0
Share

No matter what value i put in, it doesn't fade at all. I was hoping for another method that doesn't include crossfading to exist.

avatar image Owen-Reynolds · Aug 03, 2012 at 08:05 PM 0
Share

You can replace CrossFade with Play, but CrossFade is just better.

So, what happens? "it doesn't fade at all."? So do they play when you press the keys, but jerky? Or does it never play any animation at all? Or does it jerk a little when you press a key, but then quickly go back to idle?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Griffo · Aug 03, 2012 at 12:49 PM

Try something like this

 animation["Walk"].layer = 1; // Place on higher level so it will take priority over other animations
 animation["Walk"].wrapMode = WrapMode.Loop;
 animation.CrossFade("Walk");
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 Owen-Reynolds · Aug 03, 2012 at 03:54 PM 0
Share

That will make it so playing walk once will "disable" all other animations, with walk playing forever.

A nice feature of CrossFade is it auto-fades any other animation on the same layer. That allows CrossFade(idle/left/right) to also fade out walk.

$$anonymous$$oving walk up to layer 1 (they all start on zero, for the OP,) gets rid of that. You'd need to stop (or blend to weight 0) walk by hand.

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

Getting weird behaviour when blending animations of behaviour fields 1 Answer

Issue with animation 1 Answer

Animation layers: Am i limited to only one layer per animation? 0 Answers

animate pose, blend movement animation 0 Answers

Animation Blending Issue 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