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 Slider_j · Jul 15, 2014 at 04:54 AM · gameobjectgraphicsprogramming

Combining animations

Hi there, hope your all a fantastic day. I'm not sure where to ask this so i've come here as my first port of call. I have a character i have made in blender, lets just say it's a standard male human. he can run and jump, attack with a weapon etc but all individually, one at a time. I'd like him to be able to do two things at once like cast a spell while running and him do the actions for both. So he can cast while running.

So in my example to cast a spell he may only move his right arm around. For him to run he moves all his limbs and bounces up and down slightly.

What i would like to know is, is there a way to combine (in this example) the spell casting animation and the running animation so that the spell casting animation overrides the movement in the parts of the body (the right arm only) as he runs making him look like he casts the spell as he runs. I would really appreciate it if it was in C# too or just links to websites that would be helpful.

This method of combining animations would be invaluable as this is only one example of where i intent to use this "animation override" process.

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

1 Reply

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

Answer by Anti-Social Fred · Jul 15, 2014 at 05:06 AM

This answer applies mainly to the legacy animation system.

AnimationState.AddMixingTransform() is a life-saver of a method when it comes to combining different animations into 1. Consider the following:

You want to have your character run and shoot at the same time. You have 2 base animations:

  1. Standard Walk Animation (legs / torso)

  2. Standard Shooting Animation (arms / head)

The way that I implement this is by creating an Animation Controller class that's attached to my characters. Then in that class I apply the transforms. Since I already said that the walk animation only takes the legs and the torso, I will use:

                 AnimationState walk; // AnimationState that references the AnimationState in the characters' Animation class.
                 walk.AddMixingTransform(legs);
                 walk.AddMixingTransform(torso);

The second you AddMixingTransform to something, all of the other weights fall off, so during this animation the rest of the body will NOT move. That being said, if you properly manage an Animation Controller, you can check things such as:

             if (moving)
             {
                 // Play Movement Animation; ONLY LEGS MOVING! 
             }
             else
             {
                 // Play Still Animation; ONLY LEGS STILL!
             }
 
             if (attacking)
             {
                 // Play attack animation; ONLY ARMS AND HEAD!
             }


As you can see, using this way gives you full control over all of the animation combinations that you could ever wanna do. The controller continually updates the animations so you have to do almost nothing after applying the correct mixing transforms.

That being said,you can add as many mixing transforms as you want. Also, let's pretend that you want the entire arm including the hand in an animation. If the hand is a child of the arm bone, then all you have to do is add the arm bone!

In Mechanim, there's something called Body Masking which is almost the same as AddMixingTransform(). Personally, I prefer legacy because for me, text > GUI but I do suggest learning Mechanim if you want a more event-based system rather than programmatically creating one. A lot more coding with Legacy, but for me it's worth it!

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 Slider_j · Jul 15, 2014 at 06:04 AM 0
Share

Thanks, just what i was looking for! :)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

How do You Display Energy Etc Screen Indicators? 2 Answers

Control an gameobject in a specific area 0 Answers

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

Transforms are SUPER HARD! 2 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