Disclaimer: There are multiple techniques for this and each one has advantages and drawbacks. I’ll go through the technique I know best and hopefully that might point you in the right direction.
Mesh Setup
The first thing you should consider (as you mentioned) is how the mesh is constructed. The standard way is to have separate pieces that represent different parts (Head, Body, Left Arm, Left Hand, etc) that are each weighted to the armature.
Consider this example. Create 10 cubes that represent a basic character (you can scale them to look more accurate if you wish). Roughly place them in the shape of a person.
Mesh Names
Head
Body
Left Arm
Left Hand
Right Arm
Right Hand
Left Leg
Right Leg
Left Foot
Right Foot
Armature Setup
I’m not sure how much you know about rigging but the first bone you create should be a “control” bone that sits directly on the floor between the feet (this is important for later).
The next important thing is bone relation structure.
- Spine 3 should be the parent bone of ArmUpper.L and ArmUpper.R
- Spine 3 should be the parent bone of the Head bone
- Spine 1 should be the parent bone of LegUpper.L and LegUpper.R
- Control bone should be the parent of spine 1
Initial Weight & Export
- Select ALL body parts, select armature, set weight
- select ALL body parts and armature - export as FBX (call it “Player”).
- Import into Unity
Now drag the model into the scene and “unpack prefab completely”.
Look at the structure. You should see something like
Player
- Head
- Body
- Left Arm
- Left Hand
etc
Delete everything except “Player” (the parent gameobject).
Exporting Individual Parts
Now go back to blender/maya etc.
- Select only the head, select the armature, export as “Player_Head_Base.fbx”
- import into unity
- drag the object into the hierarchy and make it a child of the “Player” gameobject
- the head should appear in the correct place.
- unpack the prefab completely
- go to the mesh rig and delete all bones that are not required (the head mesh does not need the leg bones, etc)
- give it an animator controller (can still be used with avatar masks/layers for blending)
(example of modular character setup)
https://twitter.com/HavyxStudio/status/1350614198435373056
Other Stuff
If you wanted to add a hat or something, you could simply instantiate an object as a child of the head mesh’s head bone. Changing body parts simply required you delete the current part and instantiate the body part prefab as a child of the “Player” container.
Alternatively, you could weight the hat to the armature and import it as a standalone model, then instantiate it as a child of the “Player” container. This would allow you to switch hats and heads independently.
For optimisation purposes you could combine the feet so they are 1 game object not 2. Same for the arms and hands (assuming you don’t plan on letting the player equip two different types of boot at the same time)
So instead of exporting each leg individually, you might export both as “Player_Legs_Base.fbx” as I assume that in the scenario you give… the player is only going to be able to change “leg armour” or something… so keeping them individual is a waste.
In fact, the minimum would be 5 parts. This reduces total skinned meshes (and anim controllers by 50% without losing functionality). You can still use avatar masks/layers to blend animations.
Head
Body
Arms
Hands
Feet