Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Unity 5.x Animation Cookbook

You're reading from   Unity 5.x Animation Cookbook An advanced solution to all your Animation problems

Arrow left icon
Product type Paperback
Published in May 2016
Publisher Packt
ISBN-13 9781785883910
Length 328 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Maciej Szczesnik Maciej Szczesnik
Author Profile Icon Maciej Szczesnik
Maciej Szczesnik
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Working with Animations 2. Working with the Animation View FREE CHAPTER 3. 2D and User Interface Animation 4. Character Movement 5. Character Actions and Expressions 6. Handling Combat 7. Special Effects 8. Animating Cutscenes 9. Physics and Animations 10. Miscellaneous

Using animations from multiple assets

At times it is very convenient to separate animations to multiple assets. A common scenario is to have rigged models separated from animations or different animation types separated from each other (combat from movement, movement from actions, actions from cut scenes, and so on). This recipe shows how to do it for both Humanoid and Generic rigs.

Getting ready

Before we start, you should prepare and import at least two assets containing animations. If you are using a Generic rig, make sure to have the same rig in both assets. You can also use the provided example Unity project and go to the Chapter 01 Working with animations\Recipe 06 Using animations from multiple assets. There is a scene called Example.unity file there. In the scene Hierarchy you can find a Character game object. It has an attached Animator Controller in which you can find two animations: Idle and Wave. In the Rigs directory, you will find the Character.fbx asset containing only a rigged character along with the Idle.fbx and Wave.fbx assets containing the corresponding animations.

If you are exporting FBX files from Blender, make sure to disable the Add Leaf Bones option in the exporter. If you are exporting just the rig and animations (without a mesh), add an empty object to the scene. If you will not do this, your rig could be messed up a bit after import.

How to do it...

To use animations from multiple assets, you need to follow these steps:

  1. Import the files to Unity.
  2. If you are using the Generic rig, you have to set the Avatar Definition to Create From This Model on your character (or reference character if you plan to have multiple characters with the same rig). For each imported animation asset, set the Avatar Definition to Copy From Other Avatar and choose the avatar of your character or reference character. To do so, you need to unfold the character asset, find the avatar, and drag and drop it to the Source field in the Inspector tab.
  1. If you are using a Humanoid rig, you don't have to copy the Avatar Definition (you still can if your rigs are exactly the same; that way you will have fewer avatars in your project, making it easier to find the ones you need).
  2. Create or open an Animator Controller.
  3. Assign animations from different files and build transitions between them.
  4. Run the game to see the animations work.

How it works...

All Generic rigs can use animations from multiple assets that share the same Avatar Definition. To share the same Avatar DefinitionGeneric rigs have to have exactly the same rigs (the same hierarchy, the same bone names and transforms). All Humanoid rigs can use animations from multiple assets that are also set to Humanoid. Additionally, they don't need to have the same rigs because Unity automatically retargets all humanoid animations.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image