# PhysicsShapeGroup2D

> Represents a group of PhysicsShape2D and their geometry.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.Physics2DModule

```csharp
public class PhysicsShapeGroup2D
```

## Remarks

A shape group represents multiple [PhysicsShape2D](/engine/6000.7/script-reference/unityengine/physicsshape2d.md) of the same or mixed [PhysicsShapeType2D](/engine/6000.7/script-reference/unityengine/physicsshapetype2d.md) along with their geometry. It is comprised of a single list of vertices ([GetShapeVertices](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/getshapevertices.md)) along with a list of [PhysicsShape2D](/engine/6000.7/script-reference/unityengine/physicsshape2d.md) which refer to specific ranges of those vertices i.e. they index into the list of vertices. Some shape types ([PhysicsShapeType2D](/engine/6000.7/script-reference/unityengine/physicsshapetype2d.md)) use a fixed number of vertices and some use a variable number of vertices therefore this single vertices list is a compact and efficient representation for multiple [PhysicsShape2D](/engine/6000.7/script-reference/unityengine/physicsshape2d.md) in a group.

The shape group can be created by using the following methods:

* Calling [Collider2D.GetShapes](/engine/6000.7/script-reference/unityengine/collider2d/getshapes.md) where it would then represent all the shapes produced by that [Collider2D](/engine/6000.7/script-reference/unityengine/collider2d.md)

* Calling [Rigidbody2D.GetShapes](/engine/6000.7/script-reference/unityengine/rigidbody2d/getshapes.md) where it would then represent all the shapes produced by all the[Collider2D](/engine/6000.7/script-reference/unityengine/collider2d.md) attached to that [Rigidbody2D](/engine/6000.7/script-reference/unityengine/rigidbody2d.md)

* Manually populating with custom shapes by calling [AddCircle](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/addcircle.md), [AddCapsule](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/addcapsule.md), [AddPolygon](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/addpolygon.md), [AddBox](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/addbox.md) or [AddEdges](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/addedges.md).

## Constructors

| Constructor                                                                                                               | Description                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [PhysicsShapeGroup2D(System.Int32,System.Int32)](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/ctor.md) | Initializes and returns an instance of [PhysicsShapeGroup2D](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d.md). The shape group will be empty and ready for use by [Collider2D.GetShapes](/engine/6000.7/script-reference/unityengine/collider2d/getshapes.md), [Rigidbody2D.GetShapes](/engine/6000.7/script-reference/unityengine/rigidbody2d/getshapes.md) or manually adding shapes. |

## Properties

| Property                                                                                                    | Description                                                                                                                                                                     |
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [localToWorldMatrix](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/localtoworldmatrix.md) | Gets or sets a matrix that transforms the [PhysicsShapeGroup2D](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d.md) vertices from local space into world space. |
| [shapeCount](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/shapecount.md)                 | The total number of  [PhysicsShape2D](/engine/6000.7/script-reference/unityengine/physicsshape2d.md) in the shape group. (Read Only)                                            |
| [vertexCount](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/vertexcount.md)               | The total number of vertices in the shape group used to represent all [PhysicsShape2D](/engine/6000.7/script-reference/unityengine/physicsshape2d.md) within it. (Read Only)    |

## Methods

| Method                                                                                                                  | Description                                                                                                                                                                                                                                |
| ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Add](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/add.md)                                           | Adds a copy of all the [PhysicsShape2D](/engine/6000.7/script-reference/unityengine/physicsshape2d.md) and their geometry from the specified `physicsShapeGroup` into this shape group. The specified `physicsShapeGroup` is not modified. |
| [AddBox](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/addbox.md)                                     | Adds a box shape ([PhysicsShapeType2D.Polygon](/engine/6000.7/script-reference/unityengine/physicsshapetype2d/polygon.md)) to the shape group.                                                                                             |
| [AddCapsule](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/addcapsule.md)                             | Adds a capsule shape ([PhysicsShapeType2D.Capsule](/engine/6000.7/script-reference/unityengine/physicsshapetype2d/capsule.md)) to the shape group.                                                                                         |
| [AddCircle](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/addcircle.md)                               | Adds a circle shape ([PhysicsShapeType2D.Circle](/engine/6000.7/script-reference/unityengine/physicsshapetype2d/circle.md)) to the shape group.                                                                                            |
| [AddEdges](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/addedges.md)                                 | Adds an edge shape ([PhysicsShapeType2D.Edges](/engine/6000.7/script-reference/unityengine/physicsshapetype2d/edges.md)) to the shape group supporting adjacent start and end vertices.                                                    |
| [AddPolygon](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/addpolygon.md)                             | Adds a polygon shape ([PhysicsShapeType2D.Polygon](/engine/6000.7/script-reference/unityengine/physicsshapetype2d/polygon.md)) to the shape group.                                                                                         |
| [Clear](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/clear.md)                                       | Clears all the vertices and shapes from the [PhysicsShapeGroup2D](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d.md).                                                                                                     |
| [DeleteShape](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/deleteshape.md)                           | When destroying a shape at the specified `shapeIndex`, all other shapes that exist above the specified `shapeIndex` will have their shape indices updated appropriately.                                                                   |
| [GetShape](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/getshape.md)                                 | Gets the [PhysicsShape2D](/engine/6000.7/script-reference/unityengine/physicsshape2d.md) stored at the specified `shapeIndex`.                                                                                                             |
| [GetShapeData](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/getshapedata.md)                         | Gets a copy of both the shapes and vertices in the [PhysicsShapeGroup2D](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d.md).                                                                                              |
| [GetShapeVertex](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/getshapevertex.md)                     | Gets a single vertex of a shape. The vertex index is zero-based with the shape having a quantity of vertex specified by [\_vertexCount](/engine/6000.7/script-reference/unityengine/physicsshape2d/vertexcount.md).                        |
| [GetShapeVertices](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/getshapevertices.md)                 | Gets a copy of the shape vertices in the [PhysicsShapeGroup2D](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d.md).                                                                                                        |
| [SetShapeAdjacentVertices](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/setshapeadjacentvertices.md) | Sets the adjacent vertices of a shape.                                                                                                                                                                                                     |
| [SetShapeRadius](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/setshaperadius.md)                     | Sets the radius of a shape.                                                                                                                                                                                                                |
| [SetShapeVertex](/engine/6000.7/script-reference/unityengine/physicsshapegroup2d/setshapevertex.md)                     | Sets a single vertex of a shape.                                                                                                                                                                                                           |
