# Merge 2D Physics Core shapes

> To combine physics shapes into a compound shape, add a Physics Area Composite component and build up its layers, or create a composer using a PhysicsComposer object in a script.

To merge multiple physics shapes into one shape, for example to create a car with a body and two wheels, use one of the following approaches:

* Create a group of primitives
* Merge a group of custom shapes

> **Note:**
>
> This documentation is about using Pose, Area, and Constraint components. To use 2D physics in the Unity Editor using components like the Rigidbody 2D component, refer to [2D physics](/engine/6000.7/manual/unity2d/2d-physics.md.md) instead.

## Merge a group of primitives

To create a merged shape from primitives, add a **Physics Area Composite** component and build up its layers.

### Add a Physics Area Composite component

Follow these steps:

1. Select a GameObject in the **Hierarchy** window, or create an empty GameObject.
2. Add a **Physics Area Composite** component to a GameObject.
3. Set **Output** to **Segments** for a merged outline shape, or **Polygons** for a merged filled shape.

### Add a single shape

Follow these steps:

1. In the **Geometry** section of the Editor window, select **Add Geometry**.
2. In the layer Unity adds, set **Geometry** to **Circle**, **Capsule**, or **Polygon**.
3. To set the position of the shape relative to the parent GameObject, expand **Transformation** in that layer and set its properties.

To add every area attached to an existing Physics Pose component instead, select **Add Pose**. Unity references the Area components attached to the Physics Pose component, rather than copying them. The Physics Pose component goes into composite mode. Composite mode stops the Physics Pose component using its own shapes, so that Unity doesn't simulate or draw the same shapes twice.

For the full list of properties, refer to [Physics Area Composite component reference](/engine/6000.7/manual/unity2d/2d-physics-api/create-objects/reference-area-composite.md).

## Merge a group of custom shapes

To merge custom shapes, use a contour group. For example, to create an arbitrary silhouette, a shape with a hole in it, or several disconnected pieces in one area.

Follow these steps:

1. After you select **Add Geometry**, set **Geometry** to **Contour Group**.

   By default, a contour group contains one contour, the vertices for a single square.

2. To add another vertex to the contour, select **Add Vertex**.

3. Select **Add Contour** to add another shape.

You can edit the vertices in the **Inspector** window, or edit contour vertices directly in the Editor view. For more information, refer to [Visualize and edit 2D Physics Core scenes](/engine/6000.7/manual/unity2d/2d-physics-api/create-objects/debug-drawing.md).

## Control how each layer combines

To control how each layer combines with the previous layers in an outline or filled shape, expand **Composite** in the layer section, then select a value for **Operation**.

The options are:

* **OR**: Adds the shape.
* **AND**: Keeps only the areas where the new shape and the existing combined shape overlap.
* **NOT**: Subtracts the new shape from the existing combined shape.
* **XOR**: Removes the overlapping areas, but keeps the non-overlapping areas.

## Set which side of a layer faces out

To set which side of the merged layer faces out, use the **Winding** property.

* If you set **Output** to **Polygons**, set **Winding** to **CW** (clockwise) for a solid shape, or **CCW** (counter-clockwise) for a hole.
* If you set **Output** to **Segments**, set **Winding** to **CW** (clockwise) for collision on the right side of the outline, or **CCW** (counter-clockwise) for collision on the left side of the outline.

## Additional resources

* [Create complex shapes with 2D Physics Core](/engine/6000.7/manual/unity2d/2d-physics-api/create-objects/complex-shapes.md)
* [Physics Area Composite component reference](/engine/6000.7/manual/unity2d/2d-physics-api/create-objects/reference-area-composite.md)
* [Physics Pose and Physics Area components](/engine/6000.7/manual/unity2d/2d-physics-api/create-objects/pose-and-area.md)
* [PhysicsCore2D repository](https://github.com/Unity-Technologies/PhysicsExamples2D/tree/master) on GitHub
* [Visualize and edit 2D Physics Core scenes](/engine/6000.7/manual/unity2d/2d-physics-api/create-objects/debug-drawing.md)
