Book Image

Unity 5.x Animation Cookbook

By : Maciej Szczesnik
Book Image

Unity 5.x Animation Cookbook

By: Maciej Szczesnik

Overview of this book

This recipe-based practical guide will show you how to unleash the power of animation in Unity 5.x and make your games visually impeccable. Our primary focus is on showing you tools and techniques to animate not only humanoid biped characters, but also other elements. This includes non-humanoid character animation, game world creation, UI element animation, and other key features such as opening doors, changing lights, transitioning to different scenes, using physics, setting up ragdolls, creating destructible objects and more. While discussing these topics, the book will focus on mecanim, the Unity 3D animation tool, and how you can use it to perform all these tasks efficiently and quickly. It contains a downloadable Unity project with interactive examples for all the recipes. By the end of this book, you will be confident and self-sufficient in animating your Unity 3D games efficiently.
Table of Contents (17 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Importing object animation from a 3D package


In Unity, you can import not only skeletal animation but also object transform animation. It can be useful for creating complex movements, for instance, an object following a path.

Getting ready

You have to animate an object's translation, rotation, or scale in a 3D package, then export the object as FBX file. You can also download the provided example Unity project and go to the Chapter 01 Working with animations\Recipe 10 Importing object animation from a 3D package directory. There is a scene called Example.unity there. This object has a follow path animation created in Blender and exported to FBX file. It has a normal Animator Controller with that animation as default state (looped). You can run the game to see the object animate.

How to do it...

To import object animation, follow these steps:

  1. Animate an object in a 3D package (translation, rotation, and scale animations are supported).
  2. Import the object into Unity and select the Generic rig type.
  3. You can adjust animation settings normally (loop an animation for instance).
  4. Create an Animator Controller and drag and drop one of the imported animations into the Animator window to create a default animation state.
  5. Place your animated object into a scene and assign the controller to the Animator component of the object.
  6. If you run the game, the object will be animated.

How it works...

Unity imports translation, rotation, and scale animation of 3D objects from a 3D package. It makes it easy to create complex animations and use advanced features of a chosen 3D software. Make sure to bake your animations into frames before importing them to Unity (Blender bakes the exported animations to frames by default). Importing mesh animation (vertices movement) is not supported (you have to use Blend Shapes instead; we will discuss them in detail in the Animating facial expressions with Blend Shapes recipe in Chapter 5Character Actions and Expressions).