# DestroyBatch

> Destroy a batch of shapes, destroying all PhysicsShape.Contact the shapes are involved in. Any invalid shapes will be ignored including chain segment shapes created via a PhysicsChain (the chain must be destroyed)." Owned shapes will produce a warning and will not be destroyed (See PhysicsShape.SetOwner ). See PhysicsBody.MassConfiguration.

## Definition

* **Type:** Method
* **Namespace:** [Unity.U2D.Physics](/engine/6000.7/script-reference/unity/u2d/physics.md)
* **Assembly:** UnityEngine.PhysicsCore2DModule

## DestroyBatch(ReadOnlySpan\<PhysicsShape>, bool)

Destroy a batch of shapes, destroying all [PhysicsShape.Contact](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape/contact.md) the shapes are involved in. Any invalid shapes will be ignored including chain segment shapes created via a [PhysicsChain](/engine/6000.7/script-reference/unity/u2d/physics/physicschain.md) (the chain must be destroyed)." Owned shapes will produce a warning and will not be destroyed (See [PhysicsShape.SetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape/setowner.md)). See [PhysicsBody.MassConfiguration](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/massconfiguration.md).

```csharp
public static void DestroyBatch(ReadOnlySpan<PhysicsShape> shapes, bool updateBodyMass)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to destroy.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to update the body mass configuration. Not doing so is faster, especially when destroying multiple shapes.

## DestroyBatch(ReadOnlySpan\<PhysicsShape>, bool, int)

Destroy a batch of shapes, destroying all contacts the shapes are involved in. Any invalid shapes are ignored, including chain segment shapes created by a chain, which must be destroyed through their owning chain instead. A shape owned by a different owner key is skipped and left valid; a shape with no owner, or one matching the given owner key, is destroyed. One summary warning reports how many shapes were skipped this way, rather than one warning per shape.

```csharp
public static void DestroyBatch(ReadOnlySpan<PhysicsShape> shapes, bool updateBodyMass, int ownerKey)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsShape>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The shapes to destroy.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to update the body mass configuration. Not doing so is faster, especially when destroying multiple shapes.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Optional owner key returned when using [PhysicsShape.SetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape/setowner.md).

### Remarks

See [PhysicsShape.Contact](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape/contact.md), [PhysicsChain](/engine/6000.7/script-reference/unity/u2d/physics/physicschain.md), [PhysicsBody.MassConfiguration](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/massconfiguration.md) and [PhysicsShape.SetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsshape/setowner.md).
