# OverlapShape

> Returns all shapes that overlap the provided shape. The selected shape is excluded from any results and must be in this world otherwise a warning will be produced.

## Definition

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

## OverlapShape(PhysicsShape, QueryFilter, Allocator)

Returns all shapes that overlap the provided shape. The selected shape is excluded from any results and must be in this world otherwise a warning will be produced.

```csharp
public NativeArray<PhysicsQuery.WorldOverlapResult> OverlapShape(PhysicsShape shape, PhysicsQuery.QueryFilter filter, Allocator allocator = Allocator.Temp)
```

### Parameters

**** (\[PhysicsShape]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsshape)): The shape used to check overlap.**** (\[QueryFilter]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsquery/queryfilter)): The filter to control what results are returned.**** (\[Allocator]\(/engine/6000.7/script-reference/unity/collections/allocator)): The memory allocator to use for the results. This can only be [Allocator.Temp](/engine/6000.7/script-reference/unity/collections/allocator/temp.md), [Allocator.TempJob](/engine/6000.7/script-reference/unity/collections/allocator/tempjob.md) or [Allocator.Persistent](/engine/6000.7/script-reference/unity/collections/allocator/persistent.md).

### Returns

| Type                                                                                                  | Description                                                                                                                                           |
| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| [NativeArray\<WorldOverlapResult>](/engine/6000.7/script-reference/unity/collections/nativearray1.md) | The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty. |

## OverlapShape(PhysicsShape, Vector2, QueryFilter, Allocator)

Returns all shapes that overlap the provided shape. The selected shape is excluded from any results and must be in this world otherwise a warning will be produced.

```csharp
public NativeArray<PhysicsQuery.WorldOverlapResult> OverlapShape(PhysicsShape shape, Vector2 origin, PhysicsQuery.QueryFilter filter, Allocator allocator = Allocator.Temp)
```

### Parameters

**** (\[PhysicsShape]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsshape)): The shape used to check overlap.**** (\[Vector2]\(/engine/6000.7/script-reference/unityengine/vector2)): The point, in world space, the shape's local geometry is tested at. The shape's body is not moved and its position is not used, so the same shape can be tested anywhere.**** (\[QueryFilter]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsquery/queryfilter)): The filter to control what results are returned.**** (\[Allocator]\(/engine/6000.7/script-reference/unity/collections/allocator)): The memory allocator to use for the results. This can only be [Allocator.Temp](/engine/6000.7/script-reference/unity/collections/allocator/temp.md), [Allocator.TempJob](/engine/6000.7/script-reference/unity/collections/allocator/tempjob.md) or [Allocator.Persistent](/engine/6000.7/script-reference/unity/collections/allocator/persistent.md).

### Returns

| Type                                                                                                  | Description                                                                                                                                           |
| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| [NativeArray\<WorldOverlapResult>](/engine/6000.7/script-reference/unity/collections/nativearray1.md) | The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty. |
