Search Unity

Looking for Modular Characters Advice

Discussion in 'Game Design' started by Foestar, Mar 29, 2020.

  1. Foestar

    Foestar

    Joined:
    Aug 12, 2013
    Posts:
    350
    Hey, so one thing I never got into in the years of playing with game design is modular character design. And my current project I thought this would be a fun thing to delve into. I want to give the player options on how their character looks, mostly between the body outfit and head and perhaps skin color. But as I said above, I've never delved into this before so my actual knowledge on how this is best practiced is null.

    I've been looking online for info on such and even videos but haven't found anything too stand out. At this time my plan is to simply create a headless model with its base animations. Then make the head a completely separate model that attaches itself to the players rigged skeleton for a head. However, I didn't know if there were any best practices out there for dealing with these things like attaching clothing to a model rather than changing body model to a model with clothing modeled on, etc. Also changing the hue of textures or just having multiple textures with varying skin colors.

    So really all i'm looking for here is knowledge and best practice advice on where to start with this before jumping in and finding myself having to start over because of lack of foresight or ignorance into the topic.
     
  2. Kwel

    Kwel

    Joined:
    Jun 9, 2014
    Posts:
    80
    Hello,
    I'm quite interested to know as well what people usually do.
    I was looking for some solutions for my project but didn't manage to find exactly what I was looking for.

    That being said, I didn't plan to change the head nor have actual clothes so texturing was my main focus.
    I finally merged multiple textures at runtime. If this can be an option for you, it's quite easy to do.

    I applied what's explained in this video (there are 4 parts):


    I then made 3 layers with transparency (body, clothes, tie) and merged those into one texture applied to the mesh:

    Here, this allows me to change the color of the body and tie programmatically (initial color of the texture is white with transparency) and keep the clothes not impacted.

    This is the cheap trick I found so far.
    If there is any other option, I'm curious too...
     
  3. Foestar

    Foestar

    Joined:
    Aug 12, 2013
    Posts:
    350
    Interesting. I also thought about doing it through texture work alone and let the texture detail carry the weight of the players actual look. And I may end up doing this to some extent. I feel like this would be good for the base textures of my model before any heavy clothes/armor are applied. Kinda like a good starting point and would work well with changing hue of the players skin color.

    I also thought about mounting objects such as helmets, face mounts, shoulder pads, etc. All on top of a texture skin system like this.

    But I've also been reading in this thread about how they stitched meshed skinned renderers together to achieve what they wanted which was also a cool ready for the last hour.
     
    Kwel likes this.
  4. Kwel

    Kwel

    Joined:
    Jun 9, 2014
    Posts:
    80
    You could also use the texture merging to apply some nice tattoos on the skin :)

    Nice thread! Thanks a lot for sharing!
     
  5. Foestar

    Foestar

    Joined:
    Aug 12, 2013
    Posts:
    350
    Wow, I think I just figured it out. And it was a lot easier than I expected. I made my base goblin model, then rigged it. Then I extracted parts out and made a basic armor look and re-rigged that one that exact same way but with the extra vertexs added in.

    Then in Unity I made the other models get the generic avatar definition of the main model. Not sure if this was completely necessary, but as we are working with bones and meshes I figured it would be good practice.

    Then in a simple line of code to test it I made it so when I pressed the A key we changed the mesh to the armored version. And bam! It actually worked! The bones are still linked!

    Code (CSharp):
    1. public class ChangeGoblinSkinTest : MonoBehaviour
    2. {
    3.     private bool hasChanged;
    4.     [SerializeField]
    5.     private SkinnedMeshRenderer newGoblinSkin;
    6.  
    7.     private void Update()
    8.     {
    9.         if (Input.GetKeyDown(KeyCode.A) && !hasChanged)
    10.         {
    11.             hasChanged = true;
    12.             this.GetComponent<SkinnedMeshRenderer>().sharedMesh = newGoblinSkin.sharedMesh;
    13.         }
    14.     }
    15. }
    Now my players bodies can be changed to different armor types. I have the head modeled separately which can also be changed and I have it linked to the head bone manually so I can animate it independently.
     
    PolygonPros and Kwel like this.
  6. Kwel

    Kwel

    Joined:
    Jun 9, 2014
    Posts:
    80
    Wow, looks neat! I'll make sure to try this approach when I can!
     
  7. Foestar

    Foestar

    Joined:
    Aug 12, 2013
    Posts:
    350
    Alright, time for an update!

    I got the armor and everything working and at this time have the body of the character set up as a its own object labeled "Body", the head armor in the same file as its own object labeled "Head", and lastly the armor as its own object labeled "Armor". These are all rigged to the same biped and all I have to do to change armor now is rig my other armors the same way and simply change the shared mesh of the needed part.

    So what's next? I figured I would allow the player to change their skin color using your idea. Just change their material to adjust their characters skin. However, I didn't want to limit them to choosing 5 or 6 pre-made colors. I wanted instead to give them a color mixer so they could feel like they were really customizing their character with more freedom.

    However, I came to the realization that this wouldn't work. Or at least I'm not sure how to make it work. My project is a multiplayer project. The character is instantiated over the network for each player with the corresponding parts. So armor, and even the skin would be either chosen at the start of the Instantiation or set after. Either way, the player would be modifying the Color on the Skin Material. This is fine for the first person who joins alone. But when another player comes in the theory would make them also change said material to their chosen color which would change the first players as well.

    So with this I have no idea where to go with that idea and may end up limiting myself to a pre-made color selection method. I'm not gonna instant give up, but at the moment I have absolutely no idea how to get around this unless I can somehow make dummy materials during runtime that delete after the game is close and are only used to temp store material color. :eek::oops:o_O:confused:

    Either way, here's at least a few pictures showing the model with cartoon shaders and what he currently looks like with armor.

     
    Kwel likes this.
  8. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    989
    This is exactly what I looking at too.

    I wonder as I am talking with @Ony - if she is free she can further explain process and maybe how to use and import with daz3d + unity.

    It would be very helpful.
     
  9. Kwel

    Kwel

    Joined:
    Jun 9, 2014
    Posts:
    80
    That's awesome for the armor parts!! I really need to explore that.

    Regarding the skin, I don't have predefined materials for each color. I have a predefined array of colors that I use to build the texture and update the material at runtime. I did so because I wanted to have a color picker at first. But finally I made colors something you could unlock.
    So for multiplayer (I use Photon), I only send the right color on the network and each client will apply the right tint to the texture.

    If you have a conflict on the material, you could create a copy of the sharedMaterial or change properties through the renderer.
    This thread may help: https://forum.unity.com/threads/materials-clone.484503/

    Then, once 2 new players join my room, I get the right skin for everybody:
     
    PolygonPros and Foestar like this.
  10. Foestar

    Foestar

    Joined:
    Aug 12, 2013
    Posts:
    350
    Ooooh, that makes a ton of sense. I'm gonna have to play with this! Thank you for both the link and idea!
     
    Kwel likes this.
  11. Kwel

    Kwel

    Joined:
    Jun 9, 2014
    Posts:
    80
    I'm glad it helped! Good luck :)