How to put clothing/armor on a character but not remove hair or related parts of the body?

In The Sims 4, when you equip a character with a hat, for most hairstyles, the hat does not replace the hairstyle. Instead, for most hair, the hat seems to go on top or connects to the mesh of the hair. If the character has an afro for example, the hat seems to deform (not entirely remove) the hair in order to go on the character’s head.

How would I implement something like this?

When I did modding for Sims2, you just created a new body mesh for hair and clothing to go with it and built around what you had made logically, or better to say you create and conform to a form factor on your meshes, to keep your modeling work to a minimum. It’s a bit tedious but since you are removing polygons that are covered in your mesh it is a good method performance wise. I dunno about Sims 4 as I don’t mod anymore but code and model for my own stuff and Unity so I’ve no idea exactly how Sims 4 does it’s mesh attachments.

Scripting a means to alter your meshes polys during runtime using OnCollision is… probably not ideal (I’m going to say bad idea or not possible) given how slow mesh collisions work and that they don’t have anything to do with vertices/poly data that you can use to remove anything. Instead you probably want to learn to make algorithms for procedural mesh generation. If you know what I’m talking about you probably have considered it. You also have to think about where you want that done, usually during a loading screen or when there isn’t any game action happening because the calculations can be slow. Not as slow as trying to use built in collisions though. So it may not be fast enough to have equipment change happening during a multiplayer battle. Here is a primer. link text

Perhaps an intermediate method, when I’m too lazy to make a bunch of meshes, I make shape keys (called blend shapes in Unity and Maya) in blender to conform/deform/hide the places in the character/hair mesh to move where the other mesh, like a hat, hides it. You are basically making a slider in blender, that unity can use, that moves the vertices out of the way or under the attachment. You have to do this for each case that your attachment doesn’t look right. So you still need a form factor to keep your work to a minimum. You’ll need a C# script to tell it what Blend Shape to use when that item is equipped. (Blend Shapes are called Shape Key in blender, sorry if that’s redundant but just making sure you know they are almost the same but called differently in each program). I make an “OnEquipped” event that will tell the target mesh what blend shape to use when that item is equipped. Might not be as good on the polygon budget, as it doesn’t cull or remove anything, but I find it a little more neat and dynamic for some cases.

Here are some other tutorials that might help.

This one focuses on blender shape keys and characters but not exactly what you are doing. link text

This is a fairly long tutorial series that will help you with blend shapes, though it focuses on using the morphs to make custom characters in unity itself, but probably isn’t exactly what you are looking for. This is just to help you understand what you might need. link text

Maybe have the hair as a bunch of seperate points, and when the hat goes on the head, it deletes all the points it touches. Just an idea, you could use OnCollisionEnter()

There’s really only one way to make it look nice, and that is to Import your Model AND clothing into Blender, and put them together the way you want, you can even make equipping animations.
If you have a body with an armature, then putting gear on them in Blender is a breeze.

As a side note, I saw this because programmatically deforming or deleting vertices to accommodate a hat is going to be less-than-perfect.

I’ve not played the Sims games, though I’m sure the afro mesh is also swapped out when the hat is put onto the head, for a mesh that conforms to the hat.

Simple, clean and easily repeatable.