These are steps to do this in Unreal 5.7.
Get the hair model into Unreal
- In a 3 modeling software such as maya and blender, model the hair.
- Create a skeleton rig for it.
- Weight paint it and test it.
- Export as an FBX, and import to Unreal.
- Sometimes when going from blender to unreal, there is an error that the bones are too small.
- This is due to blender using meter as unit, so the values are like, 0.05 m for bone length.
- The solution to this, is scale the mesh and rig x100 in blender.
- In the FBX export settings from blender, set the scale to 0.01.
Create a physics asset
- In your unreal engine content browser, right click on the hair skeletal mesh.
- Move your mouse over the skeletal mesh actions, then create, then physics asset, then create and assign.
- Look for the option to create a physics asset.
- In the create physics asset window, set minimum bone size to 3.0, or such.
Set up the physics asset
- Open the physics asset.
- Select the root bone physics body.
- This is where the hair is at the head.
- In the details window, set the physics type to kinematic.
- This means, follow animation rather than simulation.
- Set the rest of the hair bone physics bodies, to simulated.
Create the socket for the character skeletal mesh
- A socket means, we can connect things here, to this bone on the skeleton.
- Open up the skeletal mesh for the character.
- Look at the bone hierarchy on the left.
- Right click on the head bone.
- Use the option to add a socket.
- Notice the name of this socket.
Adding a skeletal mesh component to the character blueprint
- Components means, we attach parts and features to our character.
- Open up the character blueprint.
- In the upper right, there is a window for components.
- Click once on the Character Mesh in this window.
- Now, when we add a component, the character mesh is set as the parent.
- Click the add button, to add a new component.
- Choose the skeletal mesh option, as the component.
Set up the component
- Select the skeletal mesh component you just created.
- Look at the right side details window.
- Use the setting here Skeletal Mesh, to set your hair mesh as the skeletal mesh.
- Use the setting here Socket, to set the socket to the head socket you created earlier.
- Use the tabs in the character blueprint viewport, to view your character.
- Posisition the hair.
Set up the collision settings for the hair
- Select the hair component.
- In the details window, go to the collision settings.
- Set the collision preset, to custom.
- For the collision enabled setting, set this to collision enabled.
- Object type = physics body.
- Set all the collision channels, to be ignore.
- For the collision channel here named physics body, set this to block.
Test the response
- At the top of the character blueprint window, click simulate.
- See if you like it.
Adjust the physics assets
- The character physics asset may have a bulky torso.
- In the content browser, open up the character physics asset.
- Set the size and position of the physics body capsules.
Tune the hair physics
Understanding the clipping, also called tunneling
- The game may run at 120 frames per second, or at 30 fps, or other settings.
- Let’s consider the character is really active.
- At lower frames per second, such as 30, the hair position at frame 30, may be quite a distance from where is was at frame 29.
- The hair is moving so fast, it travelled a lot in that 0.033 seconds between the two frames.
- A result is, one of the hair physics body capsules, is now clipping inside the character, when the physics simulation checks it out at frame 30.
- The physics simulation wants to teleport it out, but it is so deep, the simulation has trouble desiding which direction is out.
- So, the hair is stuck inside the character.
- The key to this, is to slow down the hair motion.
- You can do this with the angular damping setting, and the inertia tensor setting, in the hair physics asset.
Working with the physics asset settings
- In your project content browser, double click on the hair physics asset, to open it up.
- You can select physics body capsules here.
- In the lower left, there is a window called graph.
- The green boxes here are the hair physics capsules.
- The yellow boxes are the connections, between two neighboring capsules.
- These are called constraints.
- First, let’s set the constraints to stop axial rotation.
- This is twisting like when you make ropes.
- Kind of like what you do when you put your hair in a bun, for girls at least.
- Select all the constraints between all the physics body capsules.
- Look in the details window, for the setting section for angular limits.
- Here, there is Twist, Swing 1, and Swing 2.
- These relate to the 3 axes on a particular capsule.
- Just the way it works out, Swing 2 is the one relating to the hair’s twisting behaviour.
- So, set swing 2 to be locked.
- Next, let’s set the settings for the capsules.
- The key here, is to find the right recipe for angular damping, and intertia tensor, to manage the motion, but still look apealing and not static.
- Angular is a term from dynamics class, to mean, rotating around, rather than sliding left, right, up, and down.
- This is a lot of thoughtful experimenting; and understanding the behaviours of the settings mathematically, their relationships with each other, and the nature of the artifacts (errors and unattractive movement) in the physics simulation.
- It’s heuristics, which means, guess and check.
- Adding shock propagation (one of the settings), is lovely.
Example settings from my rig
I have a 5 capsule ponytail.
Here are the settings I use for the capsules.
For cc_hair_01, near the head bone,
o Enable shock propagation.
o Shock propagation alpha is 0.9.
o Use linear joint solver.
o set the Swing 1, Swing 2, and twist, to locked.
o Angular damping 10.0.
o Inertia tensor scale 9.0.
For cc_hair_02,
o Enable shock propagation.
o Shock propagation alpha is 0.9.
o Use linear joint solver.
o set the Swing 1and twsist limit to 10 degrees.
o No soft constraints.
o Restitution is 0.8.
o Angular damping is 8.0.
o Inertia tensor scale is 12.0.
For cc_hair_03,
o Enable shock propagation.
o Shock propagation alpha is 0.9.
o Use linear joint solver.
o Swing 1 and twist limit is 12 degrees.
o No soft constrainsts.
o Restitution is 0.8.
o Angular damping is 0.
o Inertia tensor scale is 15.
For cc_hair_04
o Enable shock propagation.
o Shock propagation alpha is 0.9.
o Use linear joint solver.
o Swing 1 and twist limits are 12 degrees.
o No soft constraints.
o Restitution is 0.8.
o Angular damping is 0.0.
o Inertia tensor scale is 3.0.
For cc_hair_05,
o Enable shock propagation.
o Shock propagation alpha is 0.9.
o Swing 1 and twist limit is 15 degrees.
o No soft constraints.
o Restitution is 0.8.
o Angular damping is 0.0.
o Inertia tensor scale is 1.0.