CapsuleCast
Casts a capsule against all colliders in this physics scene and returns detailed information on what was hit.
Read time 2 minutesLast updated 4 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 of the capsule.
startThe center of the sphere at the of the capsule.
endThe radius of the capsule.
The direction into which to sweep the capsule.
If true is returned, will contain more information about where the collider was hit. ().
hitInfoThe max length of the sweep.
A Layer mask that is used to selectively filter which colliders are considered 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, RaycastHit
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 of the capsule.
startThe center of the sphere at the of the capsule.
endThe 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 filter which colliders are considered when casting a capsule.
Specifies whether this query should hit Triggers.
Returns
Type | Description |
|---|---|
| int | The amount of hits stored to the |
Remarks
Additional Resources: Physics.CapsuleCastNonAlloc