Thursday 1 December 2016

Attaching armour to an armature rig in Blender

We're not entirely sure that this is the correct way to go about it. But here's how we managed to create our characters in Blender, and still maintain an object hierarchy after importing into Unity, allowing us to switch armour elements on and off at runtime.

Firstly, everything we wanted to be able to turn on and off is created in Blender as a separate model/mesh. We did this by creating the objects in one instance of Blender, and copy and paste them into the model containing our character.

This kept the UV mapping and so on, but allowed us to position armour over our soon-to-be-exported-to-Unity character.


After scaling and rotating the objects into position, we then parented each piece of armour to the rig, using automatic weights (we're using the Rigify meta-rig in this example rather than the generated rig, but the principle applies to any rig really). Sometimes, after parenting, the piece needs tweaking to get the rotation/location exactly right.

Then we select our single armour piece and enter weight-paint mode. The automatic weights mean that each piece of armour inherits all of the vertex groups from the model. We simply find the one that best matches the location of our armour, and delete all the others for the selected piece of armour.

Then, with just a single vertex group displaying influence over the armour piece, we paint it to the highest degree of red possible. In effect, a single bone (or vertex group controlled by one or more bones) moves the armour - this way it can't bend or deform as multiple bones fight for control over the armour.



To check everything's working, we saved the file and copied it into our Unity Assets folder, and dragged an instance of the character onto the stage.


Not only does the armour conform to the model/animation, but we still retain the entire object hierarchy, so that we can switch armour elements on and off for different character types/player positions in our game.


Coupled with being able to change textures at runtime, this should give our players plenty of scope for customising their own characters in the game!

Now the only thing really left to do is to create some custom animations for our orc characters. For some reason, applying humanoid animations to these particular characters ends up making them look a little bit... well, gormless.




No comments:

Post a Comment