# Cloth simulation

A garment that ships a `.yld` has cloth data: a coarse simulation sheet, the constraints holding it together, and the points pinned to the body that never move. The viewport runs that data, so a coat hangs and swings instead of standing still like a board.

It is a close preview of the game's cloth, not an exact match — it is simulated from the garment's own file, which is the same input the game uses, but not the same solver.

## Turning it on

Open the **Cloth** panel in the viewport and switch on **Simulate cloth**. That runs the `.yld`'s constraints, pins and collision.

The simulation hangs off the skeleton, so **it only moves once an animation is playing**. With the ped standing still there is nothing to swing. Turn on **Enable animation**, pick a walk, and watch the hem.

**Pause**, **Resume** and **Reset** are there for catching a single frame.

## Reading the status line

The panel says what it is actually doing, which matters because "nothing is moving" has several different causes.

| Status | What it means |
| --- | --- |
| The garment is following the simulation. | Working. |
| The garment is following the simulation, apart from *N* vertices | The binding could not place those — see **Quality** below. |
| The garment is not following the simulation yet. | Switched on, but not driving. Usually no animation is playing. |
| This garment has no `.yld` cloth data. | Nothing to simulate. Not an error. |
| The garment mesh was never matched to the cloth | Only the sim mesh moves; the garment does not follow it. |
| The cloth binding does not fit the garment on screen | The `.yld` belongs to a different mesh than the one loaded. |

Alongside it, the counts: sim vertices, garment vertices bound, constraints, collision capsules, and how many were dropped.

## Forces

| Control | What it does |
| --- | --- |
| **Wind** | Direction and strength, per axis. |
| **Gravity** | How hard the cloth falls. |
| **Damping** | How quickly motion bleeds off. Low damping keeps a coat swinging long after the step. |
| **Stiffness** | How much the constraints resist being stretched. |
| **Iterations** | How many times the solver passes over the constraints each frame. More is stiffer and more stable, and costs more. |

These are preview controls. They change what you see, not what ships — the game reads the `.yld`.

## Seeing what the simulation is doing

**Overlay** draws the machinery on top of the garment:

- **Show sim mesh** — the `.yld` wireframe. Pinned points are orange.
- **Show collision** — the body volumes the cloth is pushed out of, in green.
- **Overlay opacity** and **Hide behind the garment**. With the second off, the overlay draws on top so none of it is buried inside the mesh.

**Weight view** recolours the garment itself to answer one question at a time:

| View | What it shows |
| --- | --- |
| **Off** | The garment shaded as usual. |
| **Influence** | How much of each garment vertex the cloth drives — blue none, red all of it. |
| **Pinned** | Orange where the garment follows cloth points that are pinned and never move. |
| **Quality** | How far the binding misses the garment at rest — green under 1 mm, red at 10 mm. |

:::tip{title="Start with Quality"}
If a coat behaves oddly, look at **Quality** before touching a force. Red areas mean the binding never matched the garment to the cloth properly there, and no amount of damping will fix that — it is a problem in how the `.yld` and the mesh relate, not in the simulation.
:::

## Collision

Cloth collides with the ped's actual body, not only the handful of capsules a `.yld` happened to ship with. A garment authored against a sparse collision set still behaves, because the body underneath is real.

## When the simulation is off

With **Simulate cloth** off, a garment's cloth panels still have to go somewhere. Those vertices store simulation indices where bones normally go, so they hang from the garment's own anchor bone — stiff, but attached, and the shadow follows the same rule so it cannot tear away from the surface separately.

Simulated garments keep their own authored shading — folds, pleats, seams — rather than flattening to the coarser simulation sheet.

## Importing cloth

A `.yld` imports with its garment, so a coat authored as simulated arrives simulated. See [Importing](/cloth-tool/about-the-tool/importing).

## Related

- [3D Preview](/cloth-tool/about-the-tool/3d-preview) — the viewport and its options.
- [Animations](/cloth-tool/about-the-tool/animations) — the simulation needs a clip playing before it moves.

## Related pages

- [3D Preview](/cloth-tool/about-the-tool/3d-preview) — The centre panel renders your garment on an actual mpmfreemode01 / mpffreemode01 ped, with your real .ytd textures applied.
- [Building](/cloth-tool/about-the-tool/building) — When your project is ready, hit Build and choose the FiveM target.
- [Importing](/cloth-tool/about-the-tool/importing) — Select an item and click Import .ydd / .ytd (or right‑click an item → import).
- [Interface](/cloth-tool/about-the-tool/interface) — The main window is split into three panels.
- [Items and Textures](/cloth-tool/about-the-tool/items-and-textures) — An item is one garment or prop.
- [Texture Optimization](/cloth-tool/about-the-tool/texture-optimization) — Hand-made clothing packs are usually bloated and full of textures the game doesn't like — odd sizes, no mipmaps, wrong compression.
- [About the Tool](/cloth-tool/about-the-tool) — back to the section overview
