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 gpred · Jul 04, 2013 at 01:06 PM · animationblendingkeyframes

can an animation be blended between two frames?

can an animation be blended between two frames?

I need to be able to pause an animation at a precise frame or fraction of the way through the animation. I have been able to do this, for example to pause the animation 20% of the way through I do something like,

 framefrac = 0.20;
 
 animation.Play("someanim");
 animation["someanim"].enabled = true;
 animation["someanim"].weight = 1.0f;                
 animation["someanim"].time = framefrac*animation["someanim"].length;
 animation["someanim"].speed = 0; //to make the animation pause

What I also need to do is blend between two frames and pause the result. How would I, for example show a frame which is blended between 20% of the way through "someanim" and 70% of the way through "someotheranim"

Thanks in advance for your help (am new to Unity)

Comment
Add comment · Show 2
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 Benproductions1 · Jul 05, 2013 at 08:19 AM 0
Share

Format your code or no one will answer the question
If you don't know how, watch the tutorial video on the right

avatar image gpred · Jul 05, 2013 at 08:56 AM 0
Share

Thanks. Done.

1 Reply

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

Answer by Benproductions1 · Jul 05, 2013 at 09:11 AM

Hello,

Time and weight are 2 completely different things in the Unity animation system.
While time is obvious, think of weight as how much of this do I want.

If you have 2 animations, weighted at 0.2 and 0.8, then one animation will have 20% influence on the bones, while the other one will have 80% influence.
Weights should always add up to 1 (or things start breaking)

If you want 2 animations, "blended" at 30:70 and at certain times:

 var animation1:String;
 var animation2:String;
 
 var animation1Time:float;
 var animation2Time:float;
 
 var animation1Weighting:float;
 var animation2Weighting:float;
 
 function Start() {
     //Enable animations
     animation[animation1].enabled = true;
     animation[animation2].enabled = true;
     
     //Pause animations
     animation[animation1].speed = 0;
     animation[animation2].speed = 0;
     
     //Set the time of the animations
     animation[animation1].time = animation1Time;
     animation[animation2].time = animation2Time;
 
     //Set weighting of the animations
     //Since you seem to like percentages, I normalized the values as well
     //Just in case you use 20:70
     var magnitude:float = (animation2Weighting + animation1Weighting);
     animation[animation1].weight = animation1Weighting/magnitude;
     animation[animation2].weight = animation2Weighting/magnitude;
 }

Hope this helps,
Benproductions1

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 gpred · Jul 05, 2013 at 12:11 PM 0
Share

Thanks. That really does help and works just how I hoped it would. It seems I never need to call playanimation or blend of any kind. I do wonder if I change, say, animation2 on the next update loop if I then would have to set enable to false for the old animation2 that was enabled in the previous iteration.

avatar image Benproductions1 · Jul 06, 2013 at 12:52 AM 0
Share

That depends on what you want the animation to do. An animation can still run, even if it's weight is 0 and it's not actually applied. If you want the animation to stop however, setting enabled to false is the manual way to go :)
(You could also call .Stop)

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

16 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

Related Questions

Getting weird behaviour when blending animations of behaviour fields 1 Answer

Issue with animation 1 Answer

Blendshapes/Keyframes vs Animation Clips 0 Answers

Looping animation - Last keyframe adds extra frame 0 Answers

animate pose, blend movement 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