How do you script a 3d character creator?

Hello there, I wanted to start making a basic character creator but after browsing the net for a while i am still confused about how I can script my 3d model to have different bodygroups (hair,eyes shape and color, or body accessorys) in unity because on Blender i can just parent the different models to each other but i don’t how to do that in c#.

I am very new to this, if there are any tutorials or tips you could share i would very grateful!

Why, as a matter of fact, there ARE tutorials for this exact thing! Youtube is funny that way.

7185925--861859--Screen Shot 2021-05-28 at 8.16.12 AM.jpg

Just a friendly warning: depending on how involved you get, character creators are an EXTREMELY involved and tedious and annoyingly noodly fiddly process with user interface design and input statefulness. It is in no way what I would consider to be a “beginner task.”

My question was just to see how parenting models to each other worked through scripts, I tried youtube before posting here and most of the tutorials weren’t helpful to me because some used different 3d software for the models used or didn’t explain which properties should models have if there are any.

I did find a tutorial that I am following from MixPixVisuals which covers the scripting but doesn’t say anything about the making of the model for his tutorial

Appreciate the warning, in no way this is going to be an easy task and the main reason why I posted here was to hopefully get some tips or guidelines from experienced creators or suggestions of tutorials I could find on other websites or from certain channels and not just the “just google it” tip

TheChildGameObject.transform.SetParent( TheParentGameObject.transform);

That’s it.

SetParent optionally takes a second argument:

https://docs.unity3d.com/ScriptReference/Transform.SetParent.html

I just got done writing something like this myself. I spent a lot of time researching different methods, and general practices of doing stuff like this. Some people may say to split the body into pieces and stich them together as needed, or recommend a shader to hid things under clothing etc. I dont know what the best way is, or if my method is even useful outside of my project, but here is what I did, and it works as I need it to

First I created the my base human model and rigged it up. The base is just a body, and rig. Then I modeled the eyes, hair, clothes, etc, and skinned those meshes onto the body. (I used Maya for all this, but can also be done Blender) Only one set of each customizable part was modeled to character. This is the default look of the character when first imported in unity. So you should have a character that has a skinned mesh for each part of the character you would like to change.

Now that you have a character with a default look. You can start modeling different clothing. What I do is just take your character that you made and open it up in whatever modeling/rigging program you use, and delete everything but the body of the character, and the rig. Use the body as a reference to get clothing to line up correctly with the characters body. Once your done modeling for example a shirt for the character, delete the body and skin the mesh onto the rig.

Now export it, so you should just have the rig, and the new piece of clothing. Drag it over to unity.

Now if you want to equip that new piece of clothing, you can just do this.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class BoneRetarget : MonoBehaviour
{

    [SerializeField] SkinnedMeshRenderer currentSkin;
    [SerializeField] SkinnedMeshRenderer newSkin;
    // Use this for initialization
    void Start()
    {
        currentSkin.sharedMesh = newSkin.sharedMesh;
        currentSkin.sharedMaterials = newSkin.sharedMaterials;
    }

  
}

Obviously this is a overly simplified way of assigning new clothing, and you would want to hook this up to a UI with buttons, but this works, at least for my purposes.

My customizer does not require me to change the size of the characters height, or body shape, but this can be done with blend shapes, and will require a lot more work so that the body of the character does not show through the clothing meshes after being skinned on the default body. This method of doing things keeps 90% of the workflow inside your modeling program, and outside of unity. If you ever have issues with the clothing, and need to change something, its as simple as just modifying that piece of clothing in your modeling program, not needing to mess around with updating the character prefab or anything like that. If you have issues with body showing through clothing, you can make a shader that will make those faces invisible. Though I haven’t tried this, because I haven’t needed to.

The downside to my method is that different gender characters will need clothing modeled for that gender. So you may have the same shirt able to be applied to a male and female, but they will need to be skinned differently and be two separate unity models. So “Male Shirt 1”, “Female Shirt 1”. Also blend shapes do not work well because you will have body poke through, unless you make a shader to hide that stuff. The biggest benefit is if you work with other people, namely a artist who models clothing, its as simple as sending them your base model rigged, having them send you back the newly modeled clothing, and its just drag and drop into unity.

Hope that helps you out some.