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
1
Question by Tuah · Jun 17, 2010 at 07:01 AM · animationblendingweightgradually

Animation blending.

I've tried working with a couple of scripts for my running animations, but they don't seem to be working. What I basically want to do is animate a character's walk and run animations seamlessly. When the character's speed is less than 1, it's just walking. Between 1 and 25, it slowly graduates toward fully running, and at 25 and over, the character is full-on running.

How is this done? Perhaps there is a good reference aside from the Character Animation tutorial in Unity's site? (That one didn't help me learn, nor did it come close to working.)

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

2 Replies

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

Answer by StephanK · Jun 17, 2010 at 08:52 AM

Normally walk and run animations don't get blended in that way. The normal case would be to check if the speed is over a certain threshold and then crossfade to the run animation. Depending on how long the fade is this will be seamless. To do this use:

animation.CrossFade(newAnimClip, time);

If you want to do it your way you would have to set up the two animations with weights and then change both weights according to your speed. I never tried this and it will probably look odd, but to do this you would have to do something like this:

float maxSpeed = 25; float weightRun = speed / maxSpeed; float weightWalk = 1 - weightRun;

animation.Blend("walk", weightWalk, 0.1); animation.Blend("run", weightRun, 0.1);

As I said this isn't tested, but should give you an idea.

Comment
Add comment · Show 2 · 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 Tuah · Jun 17, 2010 at 03:30 PM 0
Share

Ah, this helped a bunch. It seems my problems earlier were due to a bad calculation and forgetting to account for an idle animation.

I Clamp01'd the weightRun just in case, and it seems to work great. It does look a bit odd at the moment due to the huge gap between speeds, but I should be able to fix that.

The speed is 'cause it's a Sonic fangame. xD

Thanks for your help, and sorry if my question was vague.

avatar image thereal_mpellegr · Nov 14, 2013 at 07:18 PM 0
Share

I'm new to unity so I'm not sure if this is a new feature or not, but I'm using a blend tree in my project and that seems to do what the OP was talking about. What this answer mentions seem to be what are called transitions. I believe these are both supported in the mecanim animation system. Just FYI for future readers.

avatar image
0

Answer by runevision · Jun 17, 2010 at 09:09 AM

You say that it doesn't work, but that doesn't provide much information. How does it not work? What results or errors do you get?

If your walk and run animations have different lengths (which is likely) you can use Animation.SyncLayer() to keep them synchronized.

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

1 Person is following this question.

avatar image

Related Questions

Play 2 animations at once 4 Answers

What am I not getting about animation weight blending? 4 Answers

Animation events play for all animations when blending? 1 Answer

Confusion about animation blending, weights 4 Answers

Blend Shapes in Unity? 4 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