BoxCast
Casts the box along a ray and returns detailed information on what was hit.
Read time 2 minutesLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- 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.
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
Center of the box.
Half the size of the box in each dimension.
The direction in which to cast the box.
If true is returned, hitInfo will contain more information about where the collider was hit. (Additional Resources: RaycastHit).
Rotation of the box.
The max length of the cast.
A Layer mask that is used to selectively ignore colliders when casting a capsule.
Specifies whether this query should hit Triggers.
Returns
Type | Description |
|---|---|
| bool | True, if any intersections were found. |
Remarks
Additional Resources: Physics.BoxCast.
BoxCast(Vector3, Vector3, Vector3, RaycastHit[], Quaternion, float, int, QueryTriggerInteraction)
Casts the box along a ray and returns detailed information on what was hit.
public int BoxCast(Vector3 center, Vector3 halfExtents, Vector3 direction, RaycastHit[] results, Quaternion orientation, float maxDistance = Infinity, int layerMask = -5, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
Parameters
Center of the box.
Half the size of the box in each dimension.
The direction in which to cast the box.
The buffer to store the results in.
Rotation of the box.
The max length of the cast.
A Layer mask that is used to selectively ignore colliders when casting a capsule.
Specifies whether this query should hit Triggers.
Returns
Type | Description |
|---|---|
| int | The amount of hits stored to the results buffer. |
Remarks
Additional Resources: Physics.BoxCastNonAlloc.