Big Trouble In Little Blender – 1.4 Initial Unity FBX Import & Animation Notes

blender-socket

Notes made during my first attempt to play animations saved into an FBX export within a Unity project.

In blender, I’d attached bones to meshes individually – After importing the fbx into Unity, I needed to find out how to play each meshes animation simultaneously.

These notes probably won’t be useful for anyone other than myself. I’m planning on building models as required, rather than in one lump – Which means I’ll forget everything in the meantime & have to relearn every model I build – To avoid this as much as possible, I’m hoping to use these posts as a reference point.

Apologies for any obvious mistakes or omissions – These notes were made as I was learning, and not necessarily as I had learnt.

blender-import

Useful site: Play Two Animations Simultaneously using Animator

From Blender – export to fbx & save directly into assets folder of the Unity project. There are notes online stating that blender files can be used directly in Unity project – Though when using blender files, I found the initial rotations and positions of the models meshes were out of place. fbx was easier/faster for me to setup & integrate.

 


 

To configure the models animation to play in a loop:
In the project pane, click on the imported model
This should display the setting in the inspector window (right side of the window)
Select the Animations button
Ensure import Animation is ticked
In the clips section you can preview each animation.
When a clip is selected it’s settings should be displayed.
Ensure Loop Time is ticked.
This should be enough to add looping.

 


 

To play multiple mesh animations simultaneously:
e.g. I had one animation assigned to the top lip mesh, a second animation for the bottom lip mesh – To get the biting animation to work I needed to play both animations at the same time

In the project screen – create animation controller component
double click the animation controller – this should set it to the animation window

From the main pane, select animator
In the project pane; find the model you are trying to animate & click the triangle symbol next to it – expanding & displaying its contents.
Within the contents, find the first animation clip you wish to use – left click & drag this into the animator window
It should automatically have a transition from entry to the animation predefined.
(If not – right click the entry square/element, select Make Transition from the context menu then left click on the animation you’ve just added)

This should setup the animation for the first mesh. For other meshes to animate simultaneously;

In the animator window create a new layer – To do this, click on the + button on left hand side of the window.

(If the + button isnt visible – the layers pane has been hidden – on the very top left of the animator pane, click on the button with two semi-circular lines (this icon is supposed to represent a closed eye) – This should change the icon to n eyeball & display the layers pane)

Clicking on the + button will create the new layer & set the animators focus to the newly created layer (click on the new layer to be sure).
From the project pane, find the model (click the triangle to expand its contents if necessary), select the animation clip for the next mesh you want to add – left click & drag this into the animators main window.

As before, Unity should automatically create a transition from entry to the animation.
On the left hand side of the animator’s window, from the list if layers, left click on the cog icon for the newly added layer & set it’s weight to 1

 


 

Now we have the model imported & the animation controller component animated – We need to create a prefab of the imported model for use in-game.

To create the prefab: left click and drag the model from the project pane into the hierarchy pane. Then left click and drag the model from the hierarchy pane back into the project pane – a prefab should be created with the same name as the imported model (the instance in the project pane can be deleted).

To animate the prefab: In the project pane, left click the prefab – This will display it’s settings in the inspector pane. In the inspector pane, expand prefabs animator component (add an animator component if one does not already exist). From here we need to populate the Controller and Avatar fields.

To populate the controller field: In the project pane, find the animation controller component, left click and drag this into the controller field of the prefabs animator component.

To populate the Avatar field: In the project pane, find the imported model, click the triangle to expand its contents, look for an element called xxxAvatar entry (e.g. for the mouth mesh, this was called the mouthAvatar – Its icon is a torso & head) – Left click and drag this into the prefabs->animators->avatar field.

This should add the animation to the prefab ready for use in-game.


Last post: 1.3 Initial Animation Notes

Contents page.


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s