A few weeks ago we shared a GIF of Lars' amazing physics-driven poncho that you can see above. The response was pretty mega (seems that everyone loves Pom Poms!) and we had multiple requests for a tutorial showing how we set it up in Unity. We're more than happy to help, so this week's blog-post will be a breakdown of the steps we took to create it.

We're aware not all our readers are game developers so we'll be trying to keep it broad and accessible to all. Hopefully even if you're not a gamedev yourself you'll still find it an interesting insight into how we achieve certain aspects of the game.

We've found this approach to be pretty flexible so I'm pretty sure it could be applied to other character elements, not just ponchos; for example, Tove's ponytail is created using a similar method. I'm sure you could apply it to a whole host of items, capes, skirts, hair, kilts, scarfs...loads of stuff to hit with the physics stick!

To begin with it's worth pointing out that we created Lars' poncho using Unity's in-built cloth. No extra plugins or asset store purchases were used to create it...so thanks Unity, great job! It's also worth pointing out that whilst this is the method we used, I'm sure there are other ways of achieving the same results or maybe even better results, but this is simply us sharing what we did. Anyway, let's crack on...

1) Create/Iterate Meshes

First things first, create the 3D mesh you want to turn into a cloth object. We use MayaLT, so this was all done in there and then exported to Unity. We modelled the cloth objects alongside the character to make sure that they were to the correct scale, but they are all exported as separate un-skinned meshes into Unity (not as part of the main character export). Single sided geometry works best, as anything with thickness has the potential to collapse and clip through itself in the physics simulation. With the single sided geometry you'll have to make your Unity shaders show the back-faces of your geometry (You can set this in your shader's subshader definition, I believe 'Cull Off' should do it).

Nothing particularity to be aware of when creating your geometry, but the key point I'd stress is that you should expect to iterate on your meshes to play around with the mesh density once you seen how it works in game.

The heavier your meshes (the more vertices/polygons they have) the more expensive the cloth will be from a performance point of view so start of with a reasonably light mesh, give it a test to see how it holds up under simulation, then add detail as you need it. The Unity set-up is pretty easy so it's quick to refine/add detail to your meshes, set-up the physics again and give it a whirl. If you're interested here is the geometry topology of Lars's poncho mesh so you can get an idea of the density used (you can see there is extra detail added at the bottom in the area that will be stretched the most).