# BoxCast

> Casts the box along a ray and returns detailed information on what was hit.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.PhysicsModule

## BoxCast(Vector3, Vector3, Vector3, RaycastHit, Quaternion, float, int, QueryTriggerInteraction)

Casts the box along a ray and returns detailed information on what was hit.

```csharp
public bool BoxCast(Vector3 center, Vector3 halfExtents, Vector3 direction, out RaycastHit hitInfo, Quaternion orientation, float maxDistance = Infinity, int layerMask = -5, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
```

### Parameters

**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): Center of the box.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): Half the size of the box in each dimension.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The direction in which to cast the box.**** (\[RaycastHit]\(/engine/6000.0/script-reference/unityengine/raycasthit)): If true is returned, hitInfo will contain more information about where the collider was hit. (Additional Resources: [RaycastHit](/engine/6000.0/script-reference/unityengine/raycasthit.md)).**** (\[Quaternion]\(/engine/6000.0/script-reference/unityengine/quaternion)): Rotation of the box.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The max length of the cast.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A [Layer mask](/engine/6000.0/manual/working-with-gameobjects/layers.md) that is used to selectively ignore colliders when casting a capsule.**** (\[QueryTriggerInteraction]\(/engine/6000.0/script-reference/unityengine/querytriggerinteraction)): Specifies whether this query should hit Triggers.

### Returns

| Type                                                          | Description                            |
| ------------------------------------------------------------- | -------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True, if any intersections were found. |

### Remarks

Additional Resources: [Physics.BoxCast](/engine/6000.0/script-reference/unityengine/physics/boxcast.md).

## BoxCast(Vector3, Vector3, Vector3, RaycastHit\[], Quaternion, float, int, QueryTriggerInteraction)

Casts the box along a ray and returns detailed information on what was hit.

```csharp
public int BoxCast(Vector3 center, Vector3 halfExtents, Vector3 direction, RaycastHit[] results, Quaternion orientation, float maxDistance = Infinity, int layerMask = -5, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
```

### Parameters

**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): Center of the box.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): Half the size of the box in each dimension.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): The direction in which to cast the box.**** (\[RaycastHit\[]]\(/engine/6000.0/script-reference/unityengine/raycasthit)): The buffer to store the results in.**** (\[Quaternion]\(/engine/6000.0/script-reference/unityengine/quaternion)): Rotation of the box.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The max length of the cast.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A [Layer mask](/engine/6000.0/manual/working-with-gameobjects/layers.md) that is used to selectively ignore colliders when casting a capsule.**** (\[QueryTriggerInteraction]\(/engine/6000.0/script-reference/unityengine/querytriggerinteraction)): Specifies whether this query should hit Triggers.

### Returns

| Type                                                       | Description                                      |
| ---------------------------------------------------------- | ------------------------------------------------ |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The amount of hits stored to the results buffer. |

### Remarks

Additional Resources: [Physics.BoxCastNonAlloc](/engine/6000.0/script-reference/unityengine/physics/boxcastnonalloc.md).
