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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by dgraal · Oct 02, 2013 at 07:45 PM · animationanimationstate

Blending two animations in a sequence?

Hello,

this is my first post in the answers, although I have been reading a lot of information trying to find the information that I could need to solve myself the answer.

For a combat system that I am implementing that includes single strikes and combos, i need in the case that the player is keychaining strikes to blend the animations, eliminating part of the beginning of some clips and the end of others as to create a smooth transition between them controlled within predefined frames.

I have reached a code that should be work, but the problem is that for some reason unknown to me, the animationstate.time doesn´t seem to keep track the running of the animations.

 void blend_animations(string animation1, string animation2, float frame end_clip1, float frame begin_clip2)
 {
     
 
     float fr=animation[animation1].clip.frameRate;
 
 
 
     animation[animation1].time = 0.0F;
     animation[animation1].wrapMode = WrapMode.ClampForever;
     animation[animation1].weight = 1.0F;
     animation[animation2].weight = 0.0F;
     animation[animation1].speed = 1.0f;
     animation[animation2].speed = 1.0f;
 
   float frameTime=(end_clip1/fr);
      
 
   animation[animation1].enabled = true;
   animation[animation1].time = 0.0f;
 
   animation.CrossFade(animation1);
      
 
    
     if(animation[animation1].time >= frameTime)
     {
     //Pause 1st animation
     animation[animation1].speed = 0.0f;
     animation[animation1].weight = 0.0F;
     animation[animation2].weight = 1.0F;
     frameTime=begin_clip2/fr;
     animation[animation2].time = frameTime;
     animation[animation2].enabled = true;
     animation.CrossFade(animation2);
  
       
    }
 }

The condition within the if is nether executed because the animationstate.time for the first animation doesn't update and stays with a value of zero.

What am I doing wrong? Is there an easier way to do it?

Cheers,

D.

Comment
Add comment · Show 1
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 Calum-McManus · Oct 03, 2013 at 01:52 PM 0
Share

Not much of an answer so i will leave it as a comment, but if you are using Unity4 you may want to look in to using $$anonymous$$echanim to set up your animation.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by dgraal · Oct 03, 2013 at 01:40 PM

Well, I have been able to make some progress, and the new function to work with some consistency, but with some random freezes that I am not able to understand what could be cause them.

Can any one, help me fixing or improving it?

Regards, D.

 void blend_animations(string animation1, string animation2)
     {
     //Enable animations
 
     float fr=animation[animation1].clip.frameRate;
     AnimationState tempState;
 
     if(!animation.IsPlaying(animation1)) 
     { 
             
  
     animation.CrossFade(animation1,0.0f,PlayMode.StopAll);
 
     }
     
 float currentTime=animation[animation1].time;
 
 
 
     animation[animation2].time = (begin_clip2/fr);
 
 
 
     if(animation[animation1].time >= (end_clip2/fr))
     {
    
        animation[animation1].weight = 0.0F;
     animation[animation2].weight = 1.0F;
     animation[animation2].time = (0.09f/fr);
     animation[animation2].enabled = true;
     if(!animation.IsPlaying(animation2)) 
          animation.CrossFade(animation2,0.0f,PlayMode.StopAll);
      }
 
 
 
 
 
     
    }
 
 
 
     
     
 }
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

15 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

Related Questions

Error in AnimationState.cpp Line: 307 1 Answer

Simple state switching to mouse over & pressed requires 2 animation clips with some parts duplicated? 1 Answer

Can I make animations snap to a frame? 1 Answer

Skeletal animation executes inconsistently and incorrectly 0 Answers

Animation Sometimes Shows Error dt >= 0 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