Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 SteveFSP · Jun 24, 2011 at 08:30 PM · animationlayercrossfadeweight

Animation: Impact of combining the use of Layer, CrossFade, and Weight

This question has to do with how combining layers, cross fade, and weight effects an animation.

Introduction Topic: Animation Scripting

Scenario

Clip: Idle

  • Default Clip

  • Looping

  • Default Layer

Clip: Wave

  • Non-looping

  • Not assigned to animation object.

About 5 seconds into the simulation, the following code is run:

 mAnimation.AddClip(waveClip, mClipName);
 mAnimation[mClipName].layer = 100;
 mAnimation.CrossFade(mClipName, 1.0f);

As expected, the wave clip fades in from 0 to 100% over 1 second, then fades back out. The idle animation continues un-interuped.

The Unexpected

Same scenario, except with the following code:

 mAnimation.AddClip(waveClip, mClipName);
 mAnimation[mClipName].layer = 100;
 mAnimation[mClipName].weight = 0.5f;  // <- Changed here.
 mAnimation.CrossFade(mClipName, 1.0f);

What I expect is the same behavior, except that the wave clip will fade in from 0 to 50%.

What is actually happening is that it fades in from 50 to 100%, so I get a sudden snap at the beginning of the crossfade.

Question

Is this behaving as expected? If so, what is the logic behind this behavior? And what should I do if I really want to fade in from 0 to 50%?

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
2
Best Answer

Answer by Waz · Jun 25, 2011 at 01:54 AM

CrossFade operates by modifying the weight (watch it change in your first code to see this). By setting the weight to 0.5 initially, you are effectively jumping the crossfade forward.

One way to get the 0 to 50% would be to put it on a lower layer and set the idle animation weight to 0.5.

Better might be to use Animation.Blend.

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 SteveFSP · Jun 26, 2011 at 03:55 PM 0
Share

Thanks. I was thinking of weight as just an input value, but it is also a control value while the clip is playing, and CrossFade always blends from the current weight to 100%. It makes sense now.

avatar image
0

Answer by ddd.du · Jun 28, 2011 at 01:00 AM

just create a separate animation just like what they did on bootcamp demo, idle, idlewhilewave, walk, walkwhilewave, etc.,Just A Suggestion Just Create A Seperate Animation Like What They Did On BootCamp Demo idle, idlewaving, walk, walkwaving, etc

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 SteveFSP · Jun 28, 2011 at 03:47 PM 0
Share

No, definitely not the way to go. That would cause the combinatorial explosion in animations that blending is designed to prevent.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Play 2 animations at once 4 Answers

Play an animation just on some parts of the body 1 Answer

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

Animation Layering 2 Answers

How to use CrossFade with anim2 when anim1 is over? 1 Answer


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