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.
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.
To import object animation, follow these steps:
- Animate an object in a 3D package (translation, rotation, and scale animations are supported).
- Import the object into Unity and select the
Generic
rig type. - You can adjust animation settings normally (loop an animation for instance).
- Create an
Animator Controller
and drag and drop one of the imported animations into theAnimator
window to create a default animation state. - Place your animated object into a scene and assign the controller to the
Animator
component of the object. - If you run the game, the object will be animated.
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 5, Character Actions and Expressions).