Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PhysicsSpace

Provides the ability to store and query information in a spatial database.
Read time 4 minutesLast updated 12 days ago

Definition

public readonly struct PhysicsSpace : IEquatable<PhysicsSpace>

Properties

Property

Description

isValidCheck if a Physics Space is valid.
memoryAllocatedGet the total memory allocated for the space, in bytes.
proxyCountGet the proxy count in the space.
rootAABBGet the root bounds that contain all the AABB proxies.
sourceWorldGet the world this space is bound to, or a default (invalid) world if the space is not bound. A space is bound by creating it with the world overload of Create.

Methods

Method

Description

CastRayFind proxies that intersect the specified ray. The results indicate that the proxy AABB intersect the specified cast ray, in no specific order.
CastShapeFind proxies that intersect the specified shape. The results indicate that the proxy AABB intersect the specified cast shape, in no specific order.
ClearProxiesClear all space proxies. You should no longer use any previously returned PhysicsSpace.ProxyHandle 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.
CloneClear any existing proxies and clone every PhysicsShape found in the world this space is bound to. Each proxy created will have a user-handle assigned as _physicsHandle. This only applies to a space bound to a world.
CreateProxyCreate a space proxy.
CreateProxyShapesCreate one proxy per shape, taking each proxy AABB, categories and user handle directly from the shape. This only applies to a space bound to a world, and every shape must be a live shape in that world.
DestroyDestroy the Physics Space.
DestroyProxyDestroy a space proxy.
GetBatchProxyAABBGet a batch of proxy AABB. If any proxy handle in the batch is invalid, no results are returned and an empty array is produced.
GetBatchProxyCategoriesGet a batch of proxy categories. If any proxy handle in the batch is invalid, no results are returned and an empty array is produced.
GetBatchProxyShapesGet a batch of proxy user handles as shapes, valid only on a space bound to a world. On a bound space every proxy user handle is a shape, so each is returned as a shape that the caller can check for validity. This only applies to a space bound to a world.
GetBatchProxyUserHandleGet a batch of proxy user handles. If any proxy handle in the batch is invalid, no results are returned and an empty array is produced.
GetProxyAABBSet the proxy physics AABB.
GetProxyCategoriesGet the proxy categories.
GetProxyUserHandleGet the proxy user handle.
OverlapAABBFind proxies that overlap the specified AABB. The results indicate that the proxy AABB overlap the specified AABB, in no specific order.
OverlapPointFind proxies that overlap the specified point. The results indicate that the proxy AABB overlap the specified point, in no specific order.
SetBatchProxyAABBSet a batch of proxy AABB, where the AABB at each index is set on the corresponding proxy at the same index. The two spans must be the same length. Any invalid proxy handle or AABB in the batch is skipped and reported with a single warning.
SetBatchProxyCategoriesSet a batch of proxy categories, where the categories at each index are set on the corresponding proxy at the same index. The two spans must be the same length. This can be an expensive operation as all ancestors need to be recalculated. Any invalid proxy handle in the batch is skipped and reported with a single warning.
SetProxyAABBSet the proxy AABB.
SetProxyCategoriesSet the proxy categories. This can be an expensive operation as all ancestors need to be recalculated.
SetProxyUserHandleSet the proxy user handle. On a world-bound space the user handle must be a live shape in the bound world.
SyncShapesRefresh every proxy from its shape, updating each proxy AABB and categories to match the live shape. This only applies to a space bound to a world. A proxy whose shape has been destroyed since it was added is skipped and reported with a single warning.

Static Methods

Method

Description

CreateCreate a Physics Space.
DestroyAllDestroy all active Physics Space.
GetSpacesGet all the currently active spaces.

Classes

Class

Description

PhysicsSpace.ShapeSpaceQuery a PhysicsSpace assuming the PhysicsSpace.ProxyHandle are all PhysicsShape.

Structs

Struct

Description

PhysicsSpace.CastResultThe narrowphase cast results.
PhysicsSpace.ProxyHandleA proxy identity added to the space.
PhysicsSpace.ProxyResultA space result from PhysicsSpace.OverlapAABB, PhysicsSpace.CastRay or PhysicsSpace.CastShape.