# Capsule Cast 2D

### Description

Casts a capsule against Colliders in the Scene, returning the first Collider to contact with it.

A *CapsuleCast* is conceptually like dragging a capsule through the Scene in a particular direction. Any object making contact with the capsule can be detected and reported.

{% hint style="info" %}
This function returns a RaycastHit2D object with a reference to the Collider that is hit by the capsule (the Collider property of the result will be NULL if nothing was hit)

The returned RaycastHit2D returns both the point and normal of the contact where the capsule would touch the Collider. It also returns the centroid where the capsule would be positioned for it to contact at that point.
{% endhint %}

**To create it**, right-click on free space in AI Tree inspector and select <mark style="color:purple;">Create Node/Tasks/Physics2D/Capsule Cast 2D.</mark>

This task node has a number of fields, that are highlighted in picture below.

<figure><img src="https://2203000093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGOxTM7Aj9oiVaIINrEkE%2Fuploads%2Fdp7nNYDxUQSo8j2a98fL%2FPhys7.png?alt=media&#x26;token=8ced7511-697b-470f-9177-662480fbede7" alt=""><figcaption></figcaption></figure>

### Fields

| Name              | Description                                                         |
| ----------------- | ------------------------------------------------------------------- |
| Node Name         | Name of node                                                        |
| Ignore Abort Self | Whether node ignores abort self or not                              |
| Origin            | Point in 2D space where the capsule originates                      |
| Direction         | Vector representing the direction to cast the capsule               |
| Size              | Size of the capsule                                                 |
| Capsule Direction | Direction of the capsule                                            |
| Max Distance      | Max length of the cast (by default: *infinity*)                     |
| Culling Layer     | Used to selectively ignore colliders when casting a Capsule Cast 2D |

### Message

| Name     | Description                                                                                    |
| -------- | ---------------------------------------------------------------------------------------------- |
| Message  | Value of message                                                                               |
| Argument | Argument of message in [Blackboard](https://renownedgames.gitbook.io/ai-tree/basic/blackboard) |
