Creating hair in Maya and Unreal Engine 4: part 6

Jun 10, 2020 at 10:00 am by nemirc


Hello again. This series of articles were not abandoned, just paused as I experimented more with hair and other engine features. In previous parts I had stated I was happy with the hairstyle. However, I decided to change a tiny detail that I was not entirely happy with. I changed the shape of the little bun at the top of her head, because the pointy part made it look bad. I decided to change it in Maya and reimport it.

Now, let’s continue with the subject. This time I am exploring actually setting up the hair for a playable character. Previously, I had just placed the hair as a child of the character and applied an animation to it, but that’s not good if you want the hair to be part of the character.

What I did was to make my own default Pawn class (using the third person’s template as a starting point). As explained in part 5, I made the hair from 2 different parts, the hair cap and the loose hair that flows down to her shoulders. In my Pawn class I added those two as components under the Mesh(Inherited) component. One thing you need to keep in mind is that doing this will only parent the hair to the mesh, you are not parenting to a specific bone. You can see below how my hierarchy looks like (ignore the “Detectpoint_Head” object, since that’s just something I added to test AI detection).

The following image shows the hair on her head. On the right side of the image I want to point out two things. First, the “Bind Groom to Skeletal Mesh” is checked. This will make the hair “stick” to the body, and if you don’t do it, the hair will simply float-follow the character as the hierarchy (described above) parents the hair to the character’s ROOT bone (depending on your setup it will be your hip bone or a ground bone used for “root transformations” (AKA moving the character around). The second thing I want to mention is that “Source Skeletal Mesh” is set. This will let your Pawn class know what skeletal mesh is being used to bind the hair.
Depending on how you want to setup your character, you may or may not need to set this one. In my case, I did because I have different versions of the character for different outfits, and I am creating sub-classes from my main class for each of them (this way I only need to program one playable character, making my work a lot easier). In my case, my “base” Amelia class is the one in underwear and barefoot, but then I have a child class where she’s wearing a dress and high- heels, so that class needed a different skeletal mesh. The sexy red bodycon dress you have seen in some images and videos is also a subclass of the first one (future outfits will derive from the barefoot or the high-heels class depending on what’s needed).
And now let’s take a look at the hair simulation settings. If you double click the hair asset in your Content Browser you are shown a window with your Groom asset details. The first thing you need to do is enable the “Enable Simulation” checkbox under the “Hair Physics” roll down. Then you need to select a Niagara Solver. I found that Cosserat Rods or Custom Solver:GroomAssetSystem worked better for me (but you should try on your own).
 

The next part that I think is important is the Bend Constraint part. There’s a part called Stiffness Scale that you can use to set how stiff the hair is along its length. I decided to create a curve, since that can be reused for other hair types. The following image shows the settings I’ve used for this.

And this is my external curve being used for the Bend Constraint Stiffness Scale.

One thing to keep in mind is that hair will need a PhysicsAsset for collisions. You don’t really need to create one, since, when you import your characters into Unreal Engine 4, 3 assets are created by default: The Skeletal Mesh, the Physics Asset and the Skeleton. All you need to do is edit your Physics Asset to adjust it to your character, and you are done. I added capsule colliders to the head to better simulate the shape of her head (and prevent the hair from getting into the head’s mesh), I adjusted the collisions on the torso using 2 capsules to more or less follow the shape of that body part and, to prevent the hair getting into her breasts’ geometry, I also added two spheres (one for each breast). You can see the forearms don’t have colliders. That’s because, originally, her arms would be down all the time so I didn’t really need to check for collisions between the forearms and the hair, but now that her default idle and walking animations show her “hugging” herself across the chest, I may need to add them.

As I worked with the hair, I kept having a specific issue where the hair moved in a very undesirable way as she walked, and the problem was even worse when she ran. You can see the video below to understand what I mean.

As I was looking for a way to fix the issue, I noticed this setting for Hair Interpolation near the end of the Details pane. The image below shows the default settings.

This sounds like the kind of setting that would affect how the hair moves along. As you see in the video above, it almost looks like it's lagging behind the character, or over-compensating for the character's movement. I figured modifying this setting would help solve the issue, and it did. This image shows the settings I used.

And here’s the result of this change.

There are still a few things that I can touch on, like improving the overall look of the hair, but that’s something for another day. In the meantime, take the time to experiment with hair and make sure to show us what you create!

Get Unreal Engine: https://www.unrealengine.com/en-US/get-now






Sign up for our newsletter

This website uses cookies to ensure you get the best experience possible More Info
Got it!