Project Zomboid

Project Zomboid

57 ratings
Hair Modding Guide
By spongie
Information on how to create custom hairstyles in Project Zomboid
   
Award
Favorite
Favorited
Unfavorite
Resources
  • Dislaik's clothing guide[web.archive.org] includes some basic information about PZ modelling in Blender. Unfortunately all of Dislaik's workshop submissions have been deleted so I've linked a web archive of the guide instead

  • Male Model[cdn.discordapp.com]

  • Female Model[cdn.discordapp.com]

  • Scavenger has also created a Blender file[cdn.discordapp.com] that includes most vanilla hair models

  • I also recommend using this website[3d-convert.com] to convert the .X models from the media\models_X\Skinned\Hair folder into .DAE files, which can then be imported into Blender.
    I recommend using converting to the .DAE filetype because I've found that it's the most reliable for converting PZ models, although the conversion might fail for some models.


Modelling Details
This section won't cover the modelling process but includes some key information for hair models, as well as some general tips that you can use for all Zomboid models.




Importing
When you import the base character models (or any models like clothing/hair) I recommend selecting Dummy01 and then setting its scale to 1 on all axes so that you can work with the model at a more reasonable size.

You can then press CTRL+A to open the "Apply Transforms" menu and apply the rotation + scale of the Dummy01 object. You should then be free to delete Dummy01 as well as Bip01_Prop and Translation_Data.

If you are importing multiple models into the same scene then it can be helpful to repeat the above process for each of them, next you can also apply the rotation + scale of the duplicate Bip01 armatures - which you should then be able to delete without breaking the rotation/scale of the models attached to it.


If you have converted a model yourself to .DAE then you may find that all of the triangles in the mesh are separated. To fix this, go into edit mode on the mesh, select all, and then press M and merge by distance.

Importing this way might also import a ton of line objects, which you will need to delete.




Parenting the model to the armature

In order to attach the mesh to the armature, you will need to select it, and then select Bip01,
You can select multiple objects by holding CTRL when selecting in the hierarchy list, or by holding Shift if you are selecting in the 3D Viewer.

Make sure your cursor is in the 3D View and then press CTRL+P to open the parenting menu, and Armature Deform to assign it.


You will then want to check the Vertex Groups of the mesh and ensure that the mesh has a Bip01_Head group. If your hairstyle is short enough then you may want to simply select your whole mesh and assign it to this vertex group - otherwise you will need to mess with Weight Painting to make sure that the hair moves correctly when the head bone is rotated.




Texture Info
You will want to use F_Hair_White, F_HairCurly_Long, F_HairCurly_Short, or F_Hair_Braids found in media\textures on the hair model, although you can also use your own custom texture.

The texture you eventually use on your hairstyle needs to be white, but the texture that you use in Blender will not affect anything, as the in-game texture will be assigned through script.





Exporting
To export your model, select your mesh and the armature, and then go to export and choose .FBX.
These are my recommended export settings:
File Structure
In C:\Users\Zomboid\mods there is a template that you can copy and use as a base.
Your folder structure will need to look like this:
HairTutorial ─mod.info ─poster.png ─media ─hairStyles ─lua ─shared ─Definitions ─Translate ─EN ─models_X ─Skinned ─Hair

Creating the Hairstyle
Inside hairStyles you'll need to create hairStyles.xml, which will be where we create the hairstyles for use in-game. This file should contain something like this:
<?xml version="1.0" encoding="utf-8"?> <hairStyles> <male> <name>M_TestHair</name> <model>skinned\hair\M_TestHair</model> <texture>F_Hair_White</texture> <alternate category="default" style="M_TestHair" /> <alternate category="Group01" style="M_TestHair" /> <alternate category="Group02" style="M_TestHair" /> <alternate category="Group04" style="M_TestHair" /> <alternate category="Group05" style="M_TestHair" /> <alternate category="Group06" style="Bound" /> <level>2</level> <trimChoices>Donny</trimChoices> <trimChoices>M_TestHair2</trimChoices> <attachedHair>true</attachedHair> </male> </hairStyles>
I will now explain what each of these lines means:

Every hairstyle you add to your mod will need to be included inside of this <hairStyles> tag.

You create a new hairstyle entry by using a <male> tag or a <female> tag, which decides which body type the hairstyle will be available for.

The name you use for the hairstyle will be its internal name, so you should make sure it does not conflict with any other hairstyle names. In this example I have included an "M_" in the name as I usually make my hairstyles available for both male and female characters, and it helps with organisation.

The model entry is where you will include the file path of the model you created. The path will automatically start inside the models_X folder. You also do not need to include a file type as the game will handle it automatically.

The texture entry is where you will include the file path of the texture you want to use for the hairstyle, it is recommended to use one of the default textures for maximum compatibility but you can include your own custom texture here instead. The texture here needs to be white, as it will be tinted in-game to the player's hair colour. The path will automatically start inside the textures folder.

The alternate categories will let you change to a different hairstyle entry when certain types of hats are equipped in-game, in order to prevent the hair from clipping through them. This is something we will return to in a later section of the tutorial.

The level is the length of the hair. You can choose the one appropriate to your hairstyle:
0 = bald
1 = short
2 = medium
3 = long

You can add multiple trimChoices to your hairstyle, which will define which hairstyles of the same length the player will be able to choose when using scissors in-game.
If you use my Spongie's Hair mod then these trim choices won't do anything, as it includes a workaround that unlocks every hairstyle regardless of the trim choices defined in them.

Finally the last relevant entry for this section is attachedHair, which you will only include if your hairstyle is a ponytail or any similar 'tied' hairstyle. This will let the player tie their regular hair into this hairstyle in-game. If this is not needed for the hairstyle you have chosen then you can delete this line entirely.
Creating the Translation File
At this point you should be able to test the mod in-game and see that the hairstyle works, but the name in the character creation menu will be very strange. This is because we will need to create a translation for it.

To do this you will need to go to media/lua/shared/Translate/EN, where we will create IG_UI_EN.txt. This file will contain this:
IGUI_EN = { IGUI_Hair_M_TestHair = "Test", IGUI_Hair_M_OtherHair = "Cool", }

IGUI_Hair_ is a prefix added to the name of every hairstyle, and M_TestHair is the name that you defined in hairStyles.xml. The "Test" will then be whatever name you want to appear in-game.

After this the name should appear in-game.
Hat Compatibility
This section will explain how to use those Alternate categories in hairStyles.xml to use custom hairstyles when wearing headwear.

It is highly recommended that you use the mod Fluffy Hair, as it modifies the hat categories of every vanilla hat item to allow for more freedom with hat groups.

If you do use Fluffy Hair then you will need to make it a required mod on your workshop page and in your mod.info file. In mod.info you will need to include
"require=FH".

This section of the tutorial will be assuming you are using Fluffy Hair.




Setup
For this example I have removed any lines that are not important:
<male> <name>M_TestHair</name> <alternate category="default" style="M_TestHair" /> <alternate category="Group01" style="M_TestHairG1" /> <alternate category="Group02" style="M_TestHairG2" /> <alternate category="Group03" style="M_TestHairG3" /> <alternate category="Group04" style="M_TestHairG4" /> <alternate category="Group05" style="M_TestHair" /> <alternate category="Group06" style="Bound" /> </male>
The categories you need to be aware of are:
Group01 = Hats
Group02 = Bandannas/Bandages
Group03 = Hoods
Group04 = Full Helmets

The style is where you will enter the name of the hairstyle that will be used. This is how we will switch to a flattened version of the hair model. You can enter the same hairstyle for multiple categories.

As you can also see in this example, I have given my hat variants a "Group1", "Group2", "Group3", and "Group4" at the end of the name so that I can keep them organised.

Before you move on to modelling, I will point out that you can enter any hairstyle for a hat category. This means that if your hairstyle is already similar to one from the vanilla game, you could enter the name of a hat variant from Fluffy Hair instead of creating your own.




Modelling
You will need to return to Blender to create new versions of your model that will need to be modified to reduce clipping with hat models as much as possible.

You need to make sure you have models that can cover the 4 hat categories
You will want to save effort by making your models fulfil as many categories as possible.



Example - Medium
This example shows models in order from Default, Group01, and Group04.

Due to the shape of my hairstyle, I made the top half of the Group01 model flattened to the head while retaining the bottom half of the shape. The Group04 model is then completely flattened around the head and neck.
I have reused Group01 for Group02 as it usually isn't worth the effort of making a unique Group02 model.
I can also get away with reusing Group04 for Group03, as the back of the hair is short enough to not clip through hoods.

This is what I personally recommend for medium-length hairstyles, as it covers all of the necessary hat categories while using as few models as possible.



Example - Ponytail
The process I use for ponytails might be a bit confusing, but I have found this to be an efficient workflow through experience.

1 is the normal untied model. 2 is the default. 3 is Group02. And finally 4 is Group04.

In order to reuse as many models as possible, I use the Group04 model for Group01. I have just duplicated Group02 and then deleted the ponytail part of the mesh so that it can be used for hats and helmets.

As this example is a ponytail variant of another hairstyle, I can reuse this Group04 model for the original hairstyle's Group03.



General Tips
For short hairstyles, you will most likely be able to create just a single flattened model for every category.

For long hairstyles you will need to create a model for Group03 which has a short back to avoid clipping.

A technique I use to create my models is to use wireframe X-ray mode so that I can edit the hair mesh to align very closely to the base head model. Doing this makes the process much easier as you won't need to import hat models to use as a template.




Creating the hat hairstyles
Next we need to create new hairstyles for each hat model.
<male><name>M_TestHairG1</name> <model>skinned\hair\M_TestHairG1</model> <texture>F_Hair_White</texture> <noChoose>true</noChoose> </male> <male><name>M_TestHairG2</name> <model>skinned\hair\M_TestHairG2</model> <texture>F_Hair_White</texture> <noChoose>true</noChoose> </male> <male><name>M_TestHairG3</name> <model>skinned\hair\M_TestHairG3</model> <texture>F_Hair_White</texture> <noChoose>true</noChoose> </male> <male><name>M_TestHairG4</name> <model>skinned\hair\M_TestHairG4</model> <texture>F_Hair_White</texture> <noChoose>true</noChoose> </male>
These are created the same way as a regular hairstyle but are much shorter.

Once again, I also recommend you add the group name (or another indicator) at the end of the model names, as it will make it much easier for you to manage your files.

The important thing you need to add is the noChoose tag, which will ensure that players and zombies cannot spawn with this hairstyle, as it will only be applied when the player is wearing an appropriate hat item.
Zombie Spawning
You can also set your hairstyle to only spawn on zombies when they meet certain conditions, such as their outfit, or how many days into the apocalypse need to have passed for it to spawn.

This technique can also be used to completely stop a hairstyle from spawning on zombies altogether, which can be useful in some situations.

Setup
You will need to navigate to media/lua/shared/Definitions and create a new LUA file called something along the lines of TestMod_HairOutfitDefinitions.lua, as long as you can recognise what the file is for it does not matter.

This file will need
require 'Definitions/HairOutfitDefinitions'
at the beginning.

Examples
Here are some examples of the types of things you can include in this file from the vanilla game:
local cat = {}; cat.name = "MohawkSpike"; cat.minWorldAge = 180; cat.onlyFor = "Punk,Bandit"; table.insert(HairOutfitDefinitions.haircutDefinition, cat);
Here you can see that the hairstyle "MohawkSpike" from hairStyles.xml is only allowed to spawn on zombies with the "Punk" or "Bandit" outfits, and only if the save game is 180 days into the apocalypse.

How to stop zombies from using a hairstyle
local cat = {}; cat.name = "M_TestHair"; cat.onlyFor = "ZombiesDontLike"; table.insert(HairOutfitDefinitions.haircutDefinition, cat);
This example will make "M_TestHair" only spawn on zombies using the "ZombiesDontLike" outfit, which does not exist - causing this hairstyle to not spawn on any zombies at all.
Links
If you are looking for new hair mods, I have created a collection listing all of the hair mods on the workshop I can find:
https://steamcommunity.com/sharedfiles/filedetails/?id=2848318698

End
Please provide feedback on what I can improve in this guide, such as what I can make clearer and what you would like me to add.
11 Comments
PALSJ Feb 13 @ 6:14pm 
hi there! thank you so much for this guide--I'm currently working on a hair mod with absolutely 0 experience in blender and have some questions...would it be possible to get in touch somehow? or do you have more resources for modding in zomboid? thank you!
Toktasune404 Nov 24, 2023 @ 1:43pm 
Hello, I was doing all the steps, but the game fails to load the model. It's in .fbx and I moved it to .x, I spent a while trying things but nothing works...
Arsenal[26] Apr 20, 2023 @ 7:00pm 
Thanks Spongie, your guide helped alot!
nerdy Feb 26, 2023 @ 8:31pm 
i think you forgot to share your FBX export settings
spongie  [author] Jan 23, 2023 @ 3:13am 
yeah my discord is spongie#5508
pemi Jan 23, 2023 @ 2:58am 
Sure I'll think about it, is there any way that I could contact you so it would be easier for us to communicate?
spongie  [author] Jan 23, 2023 @ 1:05am 
Around $12 per hairstyle I think, it'd probably depend on how complex it is but it usually only takes me about an hour for one.
pemi Jan 22, 2023 @ 11:59pm 
How much do you usually charge? I can provide you sketches and photo references.
spongie  [author] Jan 22, 2023 @ 11:14pm 
It depends on how complicated it is, since I won't have a lot of free time because of uni. Hairstyles would be fine but clothing stuff would be too time-consuming
pemi Jan 22, 2023 @ 10:52pm 
Do you take commissions?