# PhysicsComposer

> Provides the ability to compose geometry using specific operations on layers in a specific order.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.U2D.Physics](/engine/6000.5/script-reference/unity/u2d/physics.md)
* **Assembly:** UnityEngine.PhysicsCore2DModule
* **Implements:** [IEquatable\<PhysicsComposer>](https://learn.microsoft.com/dotnet/api/system.iequatable-1), [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
public readonly struct PhysicsComposer : IEquatable<PhysicsComposer>, IDisposable
```

## Static Fields

| Value                                                                                                         | Description                                                                          |
| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| [DefaultCurveStride](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/defaultcurvestride.md) | The default curve stride used when composing geometry that has a non-zero radius.    |
| [MinCurveStride](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/mincurvestride.md)         | The minimum curve stride allowed when composing geometry that has a non-zero radius. |

## Properties

| Property                                                                                                            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [isValid](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/isvalid.md)                             | Check if a Physics Composer is valid.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [layerCount](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/layercount.md)                       | Get the number of layers currently added to the Physics Composer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [layerHandles](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/layerhandles.md)                   | Get the layer handles added to the Physics Composer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [maxPolygonVertices](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/maxpolygonvertices.md)       | Get/Set the maximum number of polygon vertices to be used when composing polygon output. This should be in the range of 3 to [PhysicsConstants.MaxPolygonVertices](/engine/6000.5/script-reference/unity/u2d/physics/physicsconstants/maxpolygonvertices.md). The default is [PhysicsConstants.MaxPolygonVertices](/engine/6000.5/script-reference/unity/u2d/physics/physicsconstants/maxpolygonvertices.md).                                                                                                                                       |
| [rejectedGeometryCount](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/rejectedgeometrycount.md) | Get the number of geometries that were rejected during the last Geometry Composition. Geometry can be rejected for a number of reasons such as vertices being collinear or too close etc. Whilst "pure" geometry is always valid, this geometry is meant to be used by physics which has constraints on what it can accept. All geometry successfully created will always be valid when used by physics. If you notice thin/small gaps in the composition, this is likely to be rejected geometry. Checking this property will help determine that. |
| [useDelaunay](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/usedelaunay.md)                     | Get/Set if Delaunay tessellation is to be used. Delaunay tessellation is enabled by default and produces far superior results. When Delaunay tessellation is disabled, curved areas can produce invalid geometry which is rejected therefore increase the [\_rejectedGeometryCount](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/rejectedgeometrycount.md).                                                                                                                                                                    |

## Methods

| Method                                                                                                              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AddLayer](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/addlayer.md)                           | Add multiple Capsule Geometry layer to the Physics Composer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [ClearLayers](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/clearlayers.md)                     | Remove all layers from the Physics Composer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [CreateChainGeometry](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/createchaingeometry.md)     | Create [ChainGeometry](/engine/6000.5/script-reference/unity/u2d/physics/chaingeometry.md) from the composition by iterating all the layers added to the composition in the layer order specified, applying each operation specified. A limit is imposed on small vertex distances so be aware that this overload uses a vertex scale of [\_one](/engine/6000.5/script-reference/unityengine/vector2/one.md) so consider using the overload which allows you to increase this if required.                                                                                                                                                                                                                                                                                          |
| [CreateConvexHulls](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/createconvexhulls.md)         | Create [PolygonGeometry.ConvexHull](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/convexhull.md) from the composition by iterating all the layers added to the composition in the layer order specified, applying each operation specified. A default vertex scale of [\_one](/engine/6000.5/script-reference/unityengine/vector2/one.md) is used here.                                                                                                                                                                                                                                                                                                                                                                                                         |
| [CreatePolygonGeometry](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/createpolygongeometry.md) | Create [PolygonGeometry](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry.md) from the composition by iterating all the layers added to the composition in the layer order specified, applying each operation specified. A limit is imposed on small vertex distances so be aware that this overload uses a vertex scale of [\_one](/engine/6000.5/script-reference/unityengine/vector2/one.md) so consider using the overload which allows you to increase this if required.                                                                                                                                                                                                                                                                                      |
| [Destroy](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/destroy.md)                             | Destroy the Physics Composer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Dispose](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/dispose.md)                             | Dispose of the composer. This simply calls [PhysicsComposer.Destroy](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/destroy.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [GetGeometryIslands](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/getgeometryislands.md)       | Get the geometry islands from a previous polygon geometry composition i.e. a call to [PhysicsComposer.CreatePolygonGeometry](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/createpolygongeometry.md) or [PhysicsComposer.CreateConvexHulls](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/createconvexhulls.md). Each generated polygon or convex-hull belongs to a unique island defining a set of polygons that are connected together as they share edges. The array returned contains a series of ranges where each range is a unique connected island where the range indicates both the start index and length of the original polygon indices. The number of discovered unique islands is defined by the size of the returned array. |
| [RemoveLayer](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/removelayer.md)                     | Remove a layer from the Physics Composer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

## Static Methods

| Method                                                                                            | Description                                                                                                                                                                                                                                                                                                                                  |
| ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Create](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/create.md)             | Create a Physics Composer.                                                                                                                                                                                                                                                                                                                   |
| [DestroyAll](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/destroyall.md)     | Destroy all active Physics Composer.                                                                                                                                                                                                                                                                                                         |
| [GetComposers](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/getcomposers.md) | Get all the currently active composers.                                                                                                                                                                                                                                                                                                      |
| [ToPolygons](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/topolygons.md)     | Creates multiple [PolygonGeometry](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry.md) from the specified geometry. A limit is imposed on small vertex distances so it is recommended that the geometry is scaled appropriately rather than on the returned geometry so geometry is not discarded due to it being invalid. |

## Structs

| Struct                                                                                                          | Description              |
| --------------------------------------------------------------------------------------------------------------- | ------------------------ |
| [PhysicsComposer.LayerHandle](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/layerhandle.md) | A composer layer handle. |

## Enums

| Enum                                                                                                        | Description           |
| ----------------------------------------------------------------------------------------------------------- | --------------------- |
| [PhysicsComposer.Operation](/engine/6000.5/script-reference/unity/u2d/physics/physicscomposer/operation.md) | A composer operation. |
