# PhysicsSpace

> Provides the ability to store and query information in a spatial database.

## Definition

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

```csharp
public readonly struct PhysicsSpace : IEquatable<PhysicsSpace>
```

## Properties

| Property                                                                                             | Description                                             |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| [isValid](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/isvalid.md)                 | Check if a Physics Space is valid.                      |
| [memoryAllocated](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/memoryallocated.md) | Get the total memory allocated for the space, in bytes. |
| [proxyCount](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/proxycount.md)           | Get the proxy count in the space.                       |
| [rootAABB](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/rootaabb.md)               | Get the root bounds that contain all the AABB proxies.  |

## Methods

| Method                                                                                                     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [CastRay](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/castray.md)                       | Find proxies that intersect the specified ray. The results indicate that the proxy AABB intersect the specified cast ray, in no specific order.                                                                                                                                                                                                                                                                                                                                                                                              |
| [CastShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/castshape.md)                   | Find proxies that intersect the specified shape. The results indicate that the proxy AABB intersect the specified cast shape, in no specific order.                                                                                                                                                                                                                                                                                                                                                                                          |
| [ClearProxies](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/clearproxies.md)             | Clear all space proxies. You should no longer use any previously returned [PhysicsSpace.ProxyHandle](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/proxyhandle.md) as they may be invalid or direct to the wrong proxy in the future. The space will continue with a similar proxy capacity therefore if full de-allocation is required, the space should be destroyed and a new one created.                                                                                                                               |
| [Clone](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/clone.md)                           | Clear any existing proxies and clone all [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape.md) found in the specified [PhysicsWorld](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld.md). Each proxy created will have a user-handle assigned as [\_physicsHandle](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape/physicshandle.md). This means you can get the referenced shape by using [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape/ctor.md). |
| [CreateProxy](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/createproxy.md)               | Create a space proxy.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [Destroy](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/destroy.md)                       | Destroy the Physics Space.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [DestroyProxy](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/destroyproxy.md)             | Destroy a space proxy.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [GetProxyAABB](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/getproxyaabb.md)             | Set the proxy physics AABB.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [GetProxyCategories](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/getproxycategories.md) | Get the proxy categories.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [GetProxyUserHandle](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/getproxyuserhandle.md) | Get the proxy user handle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [OverlapAABB](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/overlapaabb.md)               | Find proxies that overlap the specified AABB. The results indicate that the proxy AABB overlap the specified AABB, in no specific order.                                                                                                                                                                                                                                                                                                                                                                                                     |
| [OverlapPoint](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/overlappoint.md)             | Find proxies that overlap the specified point. The results indicate that the proxy AABB overlap the specified point, in no specific order.                                                                                                                                                                                                                                                                                                                                                                                                   |
| [SetProxyAABB](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/setproxyaabb.md)             | Set the proxy AABB.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [SetProxyCategories](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/setproxycategories.md) | Set the proxy categories. This can be an expensive operation as all ancestors need to be recalculated.                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [SetProxyUserHandle](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/setproxyuserhandle.md) | Set the proxy user handle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

## Static Methods

| Method                                                                                     | Description                          |
| ------------------------------------------------------------------------------------------ | ------------------------------------ |
| [Create](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/create.md)         | Create a Physics Space.              |
| [DestroyAll](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/destroyall.md) | Destroy all active Physics Space.    |
| [GetSpaces](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/getspaces.md)   | Get all the currently active spaces. |

## Classes

| Class                                                                                                   | Description                                                                                                                                                                                                                                                                                                 |
| ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [PhysicsSpace.ShapeSpace](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/shapespace.md) | Query a [PhysicsSpace](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace.md) assuming the [PhysicsSpace.ProxyHandle](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/proxyhandle.md) are all [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape.md). |

## Structs

| Struct                                                                                                    | Description                                                                                                                                                                                                                                                                                                                                |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [PhysicsSpace.CastResult](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/castresult.md)   | The narrowphase cast results.                                                                                                                                                                                                                                                                                                              |
| [PhysicsSpace.ProxyHandle](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/proxyhandle.md) | A proxy identity added to the space.                                                                                                                                                                                                                                                                                                       |
| [PhysicsSpace.ProxyResult](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/proxyresult.md) | A space result from [PhysicsSpace.OverlapAABB](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/overlapaabb.md), [PhysicsSpace.CastRay](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/castray.md) or [PhysicsSpace.CastShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsspace/castshape.md). |
