Unity Cloth Simulation

From ETC Public Wiki
Revision as of 13:49, 25 April 2019 by Yikaih (talk | contribs) (Yikaih moved page Cloth Simulation to Unity Cloth Simulation: A new page will be created containing all these topics.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Unity has Cloth Simulation abilities that can also interact with colliders. Be aware that cloth simulation is a processor expensive operation, so use with caution.

  1. The easiest way to add cloth is to simply go to GameObject -> Create Other -> Cloth.
  2. Any mesh that is currently available in your Unity Project can be assigned as Cloth. Select your Cloth object in the Hierarchy panel to open it in the Inspector. Click on the small circle next to the Mesh attribute in the inspector and a window will open where you may select from the available meshes (See Figure 1). File:Clothfigure1.jpg
  3. The cloth should automatically interact with any colliders in your scene.

Note: To find out more about Interactive Cloth and all of its properties, go here: http://unity3d.com/support/documentation/Components/class-InteractiveCloth.html

Attaching Cloth to an Object

Should you, say, want to create a cape for your character, you'll certainly need to attach the cloth. In Unity, this is done through the use of colliders.

  1. First, create your cloth object and modify it however.
  2. Create colliders and place them at the intended attachment points, overlapping at least one of the Cloth's vertices each. The easiest way to create colliders is to simple create one of the basic geometric shapes inside of Unity. For example, Go to GameObject -> Create Other -> Cube. This cube will automatically have a collider attached. If you wish to make it an invisible collider, simply delete the Mesh Renderer. Do this by clicking on the gear icon on the Mesh Renderer component in the Inspector and selecting Remove Component (See Figure 2). Or simply unchecking the Checkbox next to Mesh Renderer will also do the trick. File:Clothfigure2.jpg
  3. Once again, make sure the Collider is overlapping at least some of the cloth mesh's vertices. All the overlapping points will count as attached.
  4. Select the cloth and go to the Attached Colliders section in the Inspector. Open it and under the Size section, type in however many colliders the cloth is going to be attached to. For example, the cloth will be attached to one collider, so type in 1.
  5. One the size is typed in, it should generate however many "Element" tabs right underneath. Open those. Now, simply click-and-drag the colliders in the Hierarchy Panel into the Collider second inside the element section (See Figure 3). One collider per element. File:Clothfigure3.jpg
  6. Once all colliders are assigned, hit play to check (See Figure 4). File:Clothfigure4.jpg

Skinned Cloth Simulation

Should you want to simulate clothing on a character, try out Skinned Cloth. It basically causes the vertices on a skinned mesh to jiggle around.

Note: Go here to find out more: http://unity3d.com/support/documentation/Components/class-SkinnedCloth.html