Documentation

Unity Engine


Unity Engine


PhysicsAABB

Represents a 2D axis-aligned bounding-box.
Read time 1 minuteLast updated 8 hours ago

Definition

  • Type: Struct
  • Namespace: Unity.U2D.Physics
  • Assembly: UnityEngine.PhysicsCore2DModule
public struct PhysicsAABB

Constructors

Constructor

Description

PhysicsAABB(UnityEngine.Vector2)Create an axis-aligned bounding-box that encapsulates the specified point.
PhysicsAABB(UnityEngine.Vector2,UnityEngine.Vector2)Create an axis-aligned bounding-box with the specified bounds.

Properties

Property

Description

centerGet the center of the AABB.
extentsGet the extents (half size) of the AABB.
isValidCheck if the AABB is valid. To be valid, PhysicsAABB.upperBound should be equal to or above PhysicsAABB.lowerBound.
lowerBoundThe lower-left bounding vertex. This should be equal to or lower than PhysicsAABB.upperBound.
normalizedGet a new normalized copy of the AABB ensuring that PhysicsAABB.lowerBound is lower than or equal to PhysicsAABB.upperBound.
perimeterGet the perimeter length of the AABB, which is twice the sum of its width and height.
upperBoundThe upper-right bounding vertex. This should be equal to or above PhysicsAABB.lowerBound.

Methods

Method

Description

CastRayPerform a raycast against this AABB. Nothing will be detected if the ray starts inside the AABB. To check if the ray starts inside the AABB use PhysicsAABB.OverlapPoint.
ContainsChecks if the AABB contains (completely encapsulates) the specified AABB.
NormalizeNormalize the AABB ensuring that PhysicsAABB.lowerBound is lower than or equal to PhysicsAABB.upperBound.
OverlapCheck if the specified AABB overlaps this AABB.
OverlapPointCheck if the specified point overlaps this AABB.
TranslateCreate an AABB as a translated version of the current AABB.
UnionCreate a union of the specified AABB and this AABB where resulting AABB completely encapsulates both AABB.