My Unity/Blender Notes – Working with animations

This isn’t a well-crafted blog post. Not this time – it’s just a dumping ground for workflow/findings when trying to use Blender->Unity for animations.

 

Adding armatures and bones for unity

Select the object

Press Shift A

Add the armature with a single bone

p1

Name the armature (good practice)

And make sure you rename the bone too – you will regret it if you don’t when all you see is Bone Bone Bone in your animation editors.

 

Select the object only, then shift select the armature (make sure you can see it)

p5

Now we are going to parent the bone to the object.

p6

TIP: Before doing this,  if you extended the top face of this cube many times, you could create many bones from this single bone that are all connected (go to edit mode, click the top circle, and press E for extrude on the bone), then the above step will AUTOMATICALLY connect all your faces to the bones – Instant win. Press enter to confirm its position. If snapping is on you can press ctrl to disable it temporarily while moving.

This option adds a vertex group to the object AND assigns the bone to the group – saving you from having to do it. If you want more control over vertices you have to this yourself. Your bone name must match the name of the vertex group.

To see this association, select the cube, and enter Edit mode, then highlight Cube Bone as below, and deselect/select the vertices associated with the vertex group.

p7

You’ll also notice that this action has added a deform with armature modifier to the cube

Now select the armature

Enter the pose mode

p8

Press R to rotate and move the mouse – you’ll now see that the cube moves with the armature

If you want to see your armatures/bones click XRay

p9

 

 

You might want the new bone to control different vertices – simply create another vertex group with the same name as your new bone and assign the faces it should interfere with.

p10

Don’t forget to name the bone

p11

Now add the vertex groups for the cube

 

Using the select faces tool, select the faces that should be affected by that bone, and press Assign.

Select/deselect each vertex group to see if things are good. You may need to remove all vertices from the original vertex group if you’ve extruded faces from it, but here’s what you should be aiming for. The top should bend as you bend it.

 

However, the first bone we created doesn’t independently move the base – it moves the entire object because it’s the root bone. You can extract another bone beneath it to properly react to the independent movement. Here’s another CubeBoneBottom – and the main bone has no vertex group assignment.

You can then import the .blend into Unity.

Then drag the object into the scene and bring up the animation window.

Adding ‘properties’ adds the bits you want to animate (position, rotation, scale)

You can enter big values to simulate multiple rotation as well as negative values to rotate back.

You can also edit the curves to produce different interpolation.

Click the timeline to move the keyframe position.

If you lose the animation, drag the newly created controller into the ‘animator’ component.

You can also drag-select a box over the keyframes and move them to a new timing.

However, you can’t change the shape of the curves much – so if you want elastic effects you have to do this in blender using the NLA editor, action editor, curve editor and dope sheet.

That’s a whole world of pain!

 

P.s.  I know I haven’t mentioned Actions in blender yet, but be warned…

Sometimes you want a single 3d model to contain many moving parts of separate sub-jects, as part of one animation. That’s many armatures under one action – however, blender doesn’t like this one bit. So to do this save each action as a new file e.g. model@action.blend and tie the actions together in Unity.

If you only have one armature with many bones – you’ll be fine. (e.g. a character or single set of swinging doors.

 

 

 

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