Animating Cloth and Hair

RECORDING PHYSICS FOR SECONDARY MOTION

Using Unity Version 2019.4


Secondary motion is one of the most difficult areas of keyframe animation. Done correctly, it will elevate any animation because the movement can tell us so much about a scene that we don’t know – the direction and strength of the wind, the intensity or elegance of a character’s physicality. But done even slightly wrong, it’s a prime contender to destroy immersion.



The solution for most animators, whether 2D or 3D, is to rely to varying degrees on physics simulation. In Unity3D, programs like Dynamic Bone or Obi Cloth are standard.


Why this works: If you recall any high school science, “physics” refers to the branch of science related to energy and matter, including movement. It encompasses the study of how an object moves or responds in relation to acceleration, collision, gravity, friction, and other forces. In Unity, the physics engine works to apply those forces in a natural way.


With cloth and hair, air resistance and mass play such a vital role that their secondary motion will behave differently from other parts of the character – like legs and arms. Subsequently, physics assets are a fantastic solution to apply cloth and hair movement in conjunction with body motion. These assets normally work along joints to procedurally implement physical forces along the chain. In seconds, your character (or any model, really) can go from flat and unnatural to lifelike and vibrant.


Why it might not work: There are drawbacks to using physics assets. For instance, it can be expensive from an efficiency standpoint since they are constantly calculating forces and collisions. Additionally, they require colliders to be set up to avoid clipping, which can go wayward if the mesh clips past the collider. And finally, because the movements are procedural, they can be unpredictable.


The Solution

It’s really up to you. For the most part, and in many situations, the physics engine works exceptionally well.


But there is a way to have the best of both worlds.


In version 2017.1, Unity began experimenting with the GameObjectRecorder feature, which allows you to record data from a GameObject and its children. One of it’s drawbacks is that it does not capture humanoid data but it does capture bone transforms that aren’t part of a humanoid rig like wings, hair, clothing extensions, etc. In that sense, it’s actually ideal to record secondary motion. By using the test scripting from the initial feature feedback thread, I was able to do exactly what I needed with some minor adjustments.


What you will need: