CapsuleCast
Casts a capsule against all colliders in this physics scene and returns detailed information on what was hit.
Read time 2 minutesLast updated 13 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.PhysicsModule
CapsuleCast(Vector3, Vector3, float, Vector3, RaycastHit, float, int, QueryTriggerInteraction)
Casts a capsule against all colliders in this physics scene and returns detailed information on what was hit.
public bool CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, out RaycastHit hitInfo, float maxDistance = Infinity, int layerMask = -5, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
Parameters
The center of the sphere at the start of the capsule.
The center of the sphere at the end of the capsule.
The radius of the capsule.
The direction into which to sweep the capsule.
If true is returned, hitInfo will contain more information about where the collider was hit. (Additional Resources: RaycastHit).
The max length of the sweep.
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 when the capsule sweep intersects any collider, otherwise false. |
Remarks
Additional Resources: Physics.CapsuleCast.
CapsuleCast(Vector3, Vector3, float, Vector3, RaycastHit[], float, int, QueryTriggerInteraction)
Casts a capsule against all colliders in this physics scene and returns detailed information on what was hit.
public int CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, RaycastHit[] results, float maxDistance = Infinity, int layerMask = -5, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
Parameters
The center of the sphere at the start of the capsule.
The center of the sphere at the end of the capsule.
The radius of the capsule.
The direction into which to sweep the capsule.
The buffer to store the results in.
The max length of the sweep.
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.CapsuleCastNonAlloc.