It was always my goal to use cloth sim on the character. The hair, the small pouch and the jacket just screamed to be made dynamic.
For the loth physics I chose a plugin called MagicaCloth2. It supports both bone and mesh based cloth. This was perfect as I wanted to do the hair and pouch with bones, but the jacket with mesh cloth. This would allow me to kill 2 stones with one bird.
MagicaCloth2 is a cloth simulation system that can be used with both Transform and Mesh.
With this asset you can swing anything on your character!
It works fast with Unity’s DOTS (Data-Oriented Technology Stack).
It doesn’t affect the rendering pipeline at all and doesn’t require any special shaders.
Unity Assets Store
Preparing the character for bone-based cloth sim in blender
This also called for one new step in Blender I had never done: adding bones to an already skinned character!
Luckily I was able to figure it out after a few hours of trial and error. What I needed to do was to add the bones and reparent the mesh to the armature with the setting “Armature Deform -> With Empty Groups”. This was achieved by first selecting the mesh in object mode, then command clicking (on a Mac) on the armature and then pressing CTRL-P.
This prompted the popup menu where the option was found. This setting created new, empty weight maps for all the bones in the armature, without overriding the already existing weights.
I added new bones for the small ponytails and the small pouch on the character’s hip.
I reimported the character to Unity for the cloth sim process. As the rig had changed, I dod have to rebuild the character prefab carefully to maintain all the facial animations I had set up previously.
Setting up the bone cloth sim in Unity
For this character, I will be using 2 cloth sim solvers: bone cloth and mesh cloth. The bone cloth will be used for the hair and the pouch on the character, the cloth sim will be used for the jacket.
Bone cloth
Bone cloth works by creating cloth simulations based on bones. This is great for things like ropes, hoses, locks of hair, straps, etc. It also works great for cloth, by allowing you to run the cloth sim on a far simpler structure than some layered dress or a very complicated jacket.
For this character, the obvious use cases for the bone cloth was the double ponytails and the pouch. The ponytails were simple, I just added to ponytail root bones to the root bones list of the cloth solver. The pouch required a bit more setup with one capsule collider so it would interact with the thigh when the character is moving about.
For this character, this was an extremely simple setup, but it adds a ton of secondary motion that looks nice in-game!
Mesh cloth
I am not a big fan of mesh cloth sims, as they are quite tedious to set up in-engine and when the mesh changes, the cloth setup needs to be redone, but this character is such low poly, that making the mesh paint in Unity was faster than creating the bones and skinning for the mesh in Blender! So in this case I opted to make the jacket with a second cloth solver set to mesh cloth.
Unity also has a built in cloth solver, but I find it a bit unpredictable. Magica Cloth does way better job at interacting with colliders and returning to the original mesh shape after violent movements.
Like in Unity’s built-in cloth, magic Cloth mesh cloth also requires you to paint in vertex weights for the cloth. I think it only allows you to enable / disable the solver on per vertex basis. For this character, I enabled the cloth sim on the jacket vertexes and invalidated it on most other vets.
The mesh cloth sim is set to collide with 5 colliders: hips, abdomen, chest and thighs. This seemed to be plenty accurate for most animations the character has. If at some point I see the arms penetrating the cloth too much, I can always add more colliders to the cloth sim, but I do not see that happening.
For the jacket, I set the max distance quite low, so that the cloth sim would not jump all over the place if the character has jerky movements.
Cloth props
I also changed the cloth props in the scenes to use Magica Cloth, as it uses a custom wind component and I wanted the wind in the character clothing and the prop objects to match. All props that share the same cloth settings can be added to a single cloth solver.
Adding wind interaction to the cloth feels nice. It will tie in nicely with the flowing grass, flying specks and dust particles, ripples on water etc. Wind interacting with different aspects of the scene makes the whole tie in much nicer.
Leave a Reply