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
3
Question by pickle chips · Jun 08, 2013 at 03:20 PM · animationwalkingcombineattacking

Combining two animations?

So basically, is there a way to blend two animations? I have a sword attack animation, and I have a walk animation. The sword attack animation works when idle, and then the walk obviously works while he's walking.

But how can I combine it so the sword attack works while he's walking too? Like so his upper body still attacks like the sword attack, but then his lower body (legs/hips) still work like the walk animation?

Any ideas?

thanks

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 jerobinson · Jun 08, 2013 at 03:41 PM

To achieve the result you want, you need to add a mixing transform. So basically, how this works is you define an armature in the characters body, and then every child of that armature will play one animation, while the rest play a different.

For Example:

 using UnityEngine;
 using System.Collections;
 
 public class AnimationExample : MonoBehaviour {
     public Transform upperBody; // This should be the bone from which all children will play attack animation
     
     void Start() {
         animation["SwordAttack"].AddMixingTransform(upperBody); // Adds a mixing transform using the bone transform defined above
     }
     
     void Update() {
         animation.Play("RunAnimation");
         animation.Play("SwordAttack");
     }
 }

To use this example, you would find the relevant armature in your character, then drag it onto the "upperBody" variable (or whatever).

Hope this helps ;)

Comment
Add comment · Show 4 · 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 pickle chips · Jun 08, 2013 at 06:36 PM 0
Share

Ahh ok that makes sense! Thanks! But would this not alter the sword attack animation while it's standing still though?

avatar image jerobinson · Jun 10, 2013 at 04:07 AM 0
Share

Yes it would. $$anonymous$$aybe if you try adding the mixing transform only when the player is moving?

avatar image ExpiredIndexCard · Jun 10, 2013 at 05:10 AM 0
Share

Try looking at this link: http://docs.unity3d.com/Documentation/ScriptReference/AnimationState.Add$$anonymous$$ixingTransform.html It helped me a lot and it is very clear. I would give jerobinson's answer the best because he is correct. Hope this helps :)

avatar image aaronfranke · Mar 15, 2020 at 04:05 AM 0
Share

How do I do this if my object has an Animator ins$$anonymous$$d of an Animation?

avatar image
0

Answer by Mukabr · Jun 10, 2013 at 04:28 AM

http://docs.unity3d.com/Documentation/ScriptReference/Animation.CrossFade.html

animation.CrossFade is what you need.

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 jerobinson · Jun 10, 2013 at 04:45 AM 0
Share

Crossfade will only blend between animations, but it wont allow two to play at one time.... hmmmm

avatar image bodec · Jun 10, 2013 at 05:19 AM 0
Share

you will want to use the animation.blend method.

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

18 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

Related Questions

Multiple Cars not working 1 Answer

how to make a character Animation walk,idle,Attack and death ? its should do all these things 2.5 Isometric way. 0 Answers

Walking Animation Won't Work :( 1 Answer

Creating a function to use as an event in an animation? 1 Answer

can someone show me how to play a death animation when a the game object is destroyed (javascript) 3 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