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
0
Question by n0mad · Sep 30, 2011 at 07:32 PM · animationcrossfadeanimationstateweights

Changing AnimationState weights does screw up Crossfading..

Hello, I just realized by trials and errors that changing AnimationState weights on-the-fly (= outside of Update/LateUpdate loops) does completely screw up any Crossfading based on the ones you changed.

Ex (pseudo code) : Objective : Sample a transform value from the animation I'm going to Crossfade with Anim1

1) Play(Anim1)

2) change the weight of Anim2 and then Animation.Sample() it

3) Now that Anim2 weight is 1f, Anim1 weight is automatically normalized to 0f,

4) So I have to change Anim1 weight back to 1f, in order to have Anim1 display correctly again

5) Then, launch a Crossfade(Anim2) from Anim1

Result : the crossfading goes completely weird... weird rotations, placements, etc, just as if Anim2 failed to calculate the shortest rotations from Anim1

The only explanation I find from this behaviour is because Quaternion from Anim1 were reset during the Sample() process, therefore Anim2 can't find a logical follow-up to each animated transform.

So, how are we supposed to deal with mixing Animation.Sample() and Animation.Crossfade() ?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by n0mad · Sep 30, 2011 at 08:14 PM

Ok, I found a workaround (I've created the question today, but been working on it for days). But it's a very weird workaround ...

Basically, for any Crossfade to not go south after having performed an Animation.Sample(), you have to set the old anim back by specifying its state vars (weight, time, etc) twice.

Yup, twice : one AnimationState where you put back your old anim to full weight, then Sample() again, and then one another AnimationState where you put the weight/time/enabled values you had before sampling another animationClip.

Explanation : So let's take again the example from the first post, where I want to sample a transform from Anim2, but while I'm reading Anim1.

The right thing to do is :

0) Save all Anim1 animationState values (weight, enabled, time, etc)

1) disable Anim1

2) put Anim2 on full weight (1f) and enable it

3) Animation.Sample() and pick the values you want from it

4) Disable Anim2

5) put Anim1 on full weight (1f), its initial normalizedTime (forced to 1f if Anim1 was already over), and enable it

6) Animation.Sample() to make the main Animation go back to the state it was before 1)

7) put Anim1 on the values you saved in 0)

And it works. No Crossfade weird stuff. I found this by analyzing, digging and trial/erroring for days, so I'm quite happy, but the negative point is ... how the hell was I supposed to know that ??

For short, here I have to "fake" the Anim1 transforms to a fully weighted state, send it to the player, and then put it back to its original saved weight, even if it was 0f.

Isn't it completely counter intuitive ? I can understand the technical reasons behind such a maneuver, but it doesn't feel right, as anybody who faces the problem will have to trial and error like me to reach that solution.

Isn't it a bug ?

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

2 People are following this question.

avatar image avatar image

Related Questions

Problem with animations, How to blend them?? 0 Answers

Animation Sometimes Shows Error dt >= 0 0 Answers

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

Shaking skinned mesh animations 1 Answer

'speed' is not a member of 'Object'. when pausing animation 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