# CapsuleCast

> Casts a capsule against all colliders in this physics scene and returns detailed information on what was hit.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **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.

```csharp
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

**** (\[Vector3]\(/engine/6000.7/script-reference/unityengine/vector3)): The center of the sphere at the `start` of the capsule.**** (\[Vector3]\(/engine/6000.7/script-reference/unityengine/vector3)): The center of the sphere at the `end` of the capsule.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The radius of the capsule.**** (\[Vector3]\(/engine/6000.7/script-reference/unityengine/vector3)): The direction into which to sweep the capsule.**** (\[RaycastHit]\(/engine/6000.7/script-reference/unityengine/raycasthit)): If true is returned, `hitInfo` will contain more information about where the collider was hit. ().**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The max length of the sweep.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A [Layer mask](/engine/6000.7/manual/working-with-gameobjects/layers.md) that is used to selectively filter which colliders are considered when casting a capsule.**** (\[QueryTriggerInteraction]\(/engine/6000.7/script-reference/unityengine/querytriggerinteraction)): Specifies whether this query should hit Triggers.

### Returns

| Type                                                          | Description                                                           |
| ------------------------------------------------------------- | --------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True when the capsule sweep intersects any collider, otherwise false. |

### Remarks

Additional Resources: [Physics.CapsuleCast](/engine/6000.7/script-reference/unityengine/physics/capsulecast.md), [RaycastHit](/engine/6000.7/script-reference/unityengine/raycasthit.md)

## 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.

```csharp
public int CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, RaycastHit[] results, float maxDistance = Infinity, int layerMask = -5, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
```

### Parameters

**** (\[Vector3]\(/engine/6000.7/script-reference/unityengine/vector3)): The center of the sphere at the `start` of the capsule.**** (\[Vector3]\(/engine/6000.7/script-reference/unityengine/vector3)): The center of the sphere at the `end` of the capsule.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The radius of the capsule.**** (\[Vector3]\(/engine/6000.7/script-reference/unityengine/vector3)): The direction into which to sweep the capsule.**** (\[RaycastHit\[]]\(/engine/6000.7/script-reference/unityengine/raycasthit)): The buffer to store the results in.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The max length of the sweep.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A [Layer mask](/engine/6000.7/manual/working-with-gameobjects/layers.md) that is used to selectively filter which colliders are considered when casting a capsule.**** (\[QueryTriggerInteraction]\(/engine/6000.7/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.CapsuleCastNonAlloc](/engine/6000.7/script-reference/unityengine/physics/capsulecastnonalloc.md)
