Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Character Customization woes

Discussion in 'General Discussion' started by ElMagnifico, Feb 15, 2021.

  1. ElMagnifico

    ElMagnifico

    Joined:
    Aug 27, 2018
    Posts:
    71
    Posting this in general, because I have no idea where else to put it.

    I have been experimenting with Unity for the past 6 months or so, making my own game, and it's going OK. But lately I've hit a snag. Namely, character customizaton. Most tutorials are simple "switch hair model that is a separate object attached to the head" or "change skin color" - those are all fine, but not nearly enough. I figured out blendshapes so I can give variations to body/face shapes, but that is still not enough.

    Basically, I want proper equipment and body parts - boots, gloves, clothes, cat paw arms, wings, ears, tails, etc... but HOW to do it?
    I have a 3d model that I cut into parts (arms, legs, head, torso) and all are weighted/skinned to the same armature/skeleton. How do I combine them in unity? How do I make them act as one? I never found a proper tutorial for that.
    Furthermore, if I expert everything as one model (baseline torso, arms, legs, head, together with all the variations), won't that complicate things? Not only the model size, but the number of object in the scene? Performance is something that gnaws at the back of my head, so I'm thinking of simply instantiating things like wings/tail from a list, and hair would probably be better done with the same methods as arms/legs.


    And lastly, blenshapes - yes or no? I've come across a different method that scales bones, and the advantage of that one seems to be that you can actually shorten arms/legs, but setting it up looks like it will require a lot of extra bones. and I found no tutorial on that either.

    So any hint or advice would be appreciated.
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,323
    YOu need to look into "UMA" system. Which is Unity Multipurpose Avatar.
    https://assetstore.unity.com/packages/3d/characters/uma-2-unity-multipurpose-avatar-35611

    When customizing, in general, you make every piece of clothing or gear and make it match every other piece of clothing or gear. The easiest way to do it would be to export a model split into pieces with ALL possible clothing options already visible, and then switch on/off the ones you want at runtime.

    The more complex (but more flexible) option would be to develop pieces of gear separate, but have them attached to the same skeleton. Then, at runtime you'd MERGE them into a single mesh which is not necessarily trivial unless you're used to working with geometry as a programmer.

    But the most realistic scenario would be to take a look at UMA.
     
    angrypenguin likes this.
  3. ElMagnifico

    ElMagnifico

    Joined:
    Aug 27, 2018
    Posts:
    71
    I actually downloaded UMA, but haven't gotten around to checking it out yet. It seemed good, but I kinda want to get to the bottom of things and learn, instead of using pre-made assets. Don't know how it would be for my needs (mosntergirls/kemnomimi).

    Yeah, the way I currently create character is as instantiated game objects that are always in the scene, just deactivated until I select them. If I have 20 of them, and each has every cloth/body part as part of the mesh, that would add up. Don't know how good Unity performs with many inactive objects.

    You can see what I'm going for:


    looking at games like Skyrim, Mount and Blade or Sim3, different cloth/body parts are separate objects. Merging into a single mesh at runtime... don't know how complex that is. Don't suppose there are tutorials on that?
     
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,009
    Speaking about UMA, when I create new cloth do I need to rig it or it will be done automatically by UMA ?
    Because I assume that UMA clothes are rigged models that are just copying bones positions from character model.
     
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,323
    Character customization is not exactly trivial thing to do, unless you're swapping attachments. Uma has been in development for a long time, and to match its feature set you'll have sacrifice a few months of work. And that's if you're really good at programming.

    Doubtful. It is an advanced topic.

    1. I believe you'll have to rig the clothes.
    2. UMA does not only copy bone positions, but also deals with limb length. People can have shorter/longer arms and so on.
     
    angrypenguin likes this.
  6. ElMagnifico

    ElMagnifico

    Joined:
    Aug 27, 2018
    Posts:
    71
    I'll give UMA a go. I just hope it fits the bill.

    I'm not sure I want to go too far on the realism scale, that makes working with models more difficult.
     
  7. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,323
    You can create your own types of characters. The process is a bit more involved, though.
     
  8. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,511
    koirat likes this.
  9. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,009
    Cool article, pity some links are broken.
     
  10. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,511
    OMG I'll have to fix those. They should be easily googleable though. With upgrades of both Unity and Blender since I wrote the article, things got a little stale. Part 2 of the article would be just as informative to the OP.
     
  11. Havyx

    Havyx

    Joined:
    Oct 20, 2020
    Posts:
    140
    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).

    upload_2021-2-19_19-49-1.png

    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

    upload_2021-2-19_19-49-54.png


    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


    upload_2021-2-19_20-13-31.png
     
    Last edited: Feb 19, 2021
  12. mbussidk

    mbussidk

    Joined:
    May 9, 2017
    Posts:
    66
    I have published an add-on for Invector third person controller which includes a clothing system (which will also be in my upcoming third character controller) and I've published a video on how to copy blend shapes to make a morph able character, extract meshes from a CC3 character, add the blend shapes to the clothes and use them with a character which can change shape. While all the examples relate to my asset, the technique is universal.
    You can find my asset here: https://assetstore.unity.com/packages/tools/game-toolkits/eadon-rpg-for-invector-183202
    and the video here:


    Hope this helps you.
     
  13. ElMagnifico

    ElMagnifico

    Joined:
    Aug 27, 2018
    Posts:
    71
    Thank you very much.
    It does indeed help a lot.