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 EVTsrl · Mar 07, 2014 at 01:58 PM · animationcrossfade

Functioning of crossfadequeued and crossfade

I have to play animations one after another. Something like that:

 Action()
 {
    animation.Play("idle");
    animation.Play("run");
    animation.Play("walk");
    animation.Play("idle");
 }

If i use PlayQueued it works fine but there is a "jump" between animation. So i think that is better if I use CrossFade or CrossFadeQueued. I try a lot of time with these functions but they dont work (obv my fault). Sometimes first animation never stop, sometimes only the last animation starts ecc ecc. Can you help me? :|

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
0

Answer by YoungDeveloper · Mar 07, 2014 at 02:03 PM

For now, if you will call Action() method, all animations will be played. You could use switch case statement to call specific animation using just one method.

 Action(1); //will play idle
 Action(3); //will play walk
 
 Action(int state){
     switch (state){
     case 1:
       animation.Play("idle");
       break;
     case 2:
       animation.Play("run");
       break;
     case 3:
       animation.Play("walk");
       break;
     case 4:
       animation.Play("idle");
       break;
     }
 }
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 EVTsrl · Mar 07, 2014 at 02:44 PM 0
Share

thanks for answer. BTW I used playqueued. I write "play" only for make an example. $$anonymous$$y problem is that i have to run these animations one after another in sequence and not "when I press button X play animX and when press button Y play animY. :(

avatar image
0

Answer by Owen-Reynolds · Mar 07, 2014 at 03:29 PM

You're right about Play making the bones jump. Play snaps to the first animation frame, whereas CrossFade smooths from the previous animation to the new one over a few frames. It also works like Play if there was no previous animation. So there's never any reason to use Play. CrossFade is just better.

Your problem with CrossFadeQueued is probably that it only starts after the previous animation stops. A looping or clampForever animation never stops. CFQ only works if the current animation is PlayOnce (or Default?)

If you really need to walk for a bit then sit, a coroutine might help: CrossFade("walk"); WaitForSeconds(2.0f); CrossFade("sit");. But those are hard to interrupt properly (if you jump after a second, hard to cancel the sit.) Could just use flags and timers, such as: if(action==1 && Time.time>startedAction+2.0f) { CrossFade("run"); action=2; startedAction=Time.time; }

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

21 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with speed reset after crossfadeQueued 0 Answers

Play one animation after another... need help with Queued 1 Answer

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

Animations don't crossfade when changing 1 Answer

CrossFade to Specific Animation Time (Coordinate Animations) 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