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
5
Question by GuyFawkes · Aug 27, 2011 at 08:15 PM · animationcharactergun

How do I run two animations at once on the same game object?

I have a walk animation and a gun animation. I want to be able to wield the gun, and walk at the same time. Is there any way to do this?

EDIT: Please help me with the comment I just made on SilverTabby's question.

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

Answer by SilverTabby · Aug 28, 2011 at 12:59 AM

You need to use Animation.Blend

By blending two animations together, you can achieve the result you are looking for.

Blending works by taking the bone movements of the first animation, and averaging those movements with another animation based on the weight value - creating a smooth result of the animations

Using blending, you can both walk and talk at the same time, or move from an active animation to an idle animation smoothly, and many other things.

note: 0 and X averages to X, so blending a head bob with walking will not make you walk slower

Comment
Add comment · Show 6 · 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 Owen-Reynolds · Aug 28, 2011 at 01:55 AM 0
Share

You won't walk any slower, but the strides will be averaged with the other motion, like you said. An all-bone walk blended with an all-bone head-bob gives short half-strides and half the headbob. X degrees averaged with 0 degrees gives X/2 degrees.

Now, if headbob was created only on head bones, I'm not sure what blending does to the feet.

avatar image GuyFawkes · Aug 28, 2011 at 07:13 PM 0
Share

Can you give me an example of blending two animations? I'm still pretty new to Unity. (I read the Animation.Blend page, but it didn't really give any examples)

avatar image Owen-Reynolds · Aug 29, 2011 at 03:18 AM 1
Share

Set one on a higher layer (they are normally on 0) and give it a weight less than 100%. In this, bob plays at 40% and walk gets the rest:

animation.Play("walk"); animation["bob"].layer=1; animation.Play("bob"); animation["bob"].weight=0.4f;

avatar image CalebFnord · Dec 13, 2012 at 11:12 AM 0
Share

@Owen - Layering worked for me, thanks!

avatar image MagicStyle · Nov 12, 2017 at 10:28 PM 0
Share

Link is dead

Show more comments
avatar image
2

Answer by Owen-Reynolds · Aug 28, 2011 at 01:47 AM

Three ways to continuously combine two animations. See the unity animation docs for examples. Either of the first two should work for you. #1 is easiest:

o Limit them (using AddMixingTransform) to various bones. Could play walk, and play gunAim over it (on a higher layer) limited to arms only.

o Add one to the other. Suppose walk has the arms in rest pos, but swaying a little; and run has them in rest, swaying more. Can set gunAim as as Additive animation, and play on a higher layer. You'll get the walk arm-sway, with the gun aim added to it. Can also use the limit-to-bones trick. Problem with this is the animator had to plan for it.

o Blend/Average them. This plays them half and half (or whatever ratio.) It always looks bad unless the two animations are extremes of the same general motion. For example blending "big arm pump" with idle in bigger percents as you run faster.

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

11 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

Related Questions

FPS Multiplayer character animation / behaviour 0 Answers

How to set legacy on an animation? 1 Answer

Directing character's fist to a specific position 1 Answer

Character Animation Import Problem 0 Answers

Base Model Animation 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