# Collision Detector

This includes:

* Ground detection
* Slope detection
* Wall detection
* Ledge detection

The system provides the core collision information required by all gameplay modules.

***

## Component

```
CollisionDetector
```

***

## Responsibilities

The Collision Detector handles:

* Grounded state checks
* Slope normal calculation
* Wall detection
* Ledge detection
* Surface angle analysis

This component is required for:

* Movement Module
* Jump Module
* Wall Module
* Ledge Module

***

## Ground Check

The Ground Check section controls ground and slope detection.

***

## Left Ground Check

### LeftGroundCheck

Transform used for left-side ground detection.

| Setting           | Description                |
| ----------------- | -------------------------- |
| Left Ground Check | Left edge ground detection |

Used for:

* Slope detection
* Edge stability
* Ground angle calculation

***

## Center Ground Check

### CenterGroundCheck

Transform used for center ground detection.

| Setting             | Description             |
| ------------------- | ----------------------- |
| Center Ground Check | Center ground detection |

This acts as the primary grounded check.

***

## Right Ground Check

### RightGroundCheck

Transform used for right-side ground detection.

| Setting            | Description                 |
| ------------------ | --------------------------- |
| Right Ground Check | Right edge ground detection |

Used for:

* Slope handling
* Stable grounding
* Surface analysis

***

## Ground Check Distance

Controls the raycast distance used for ground detection.

| Setting               | Description           |
| --------------------- | --------------------- |
| Ground Check Distance | Ground raycast length |

Lower values:

* Require more precise check placement

Higher values:

* Increase detection range
* May cause inaccurate grounding

Recommended Range:

```
0.1 – 0.3
```

***

## Ground Layer

Defines which layer is treated as ground.

| Setting      | Description            |
| ------------ | ---------------------- |
| Ground Layer | Ground collision layer |

This layer is used for:

* Grounded checks
* Slope detection
* Landing detection

Recommended:

```
Ground
```

***

## Slope Check Distance

Controls the distance used for slope normal detection.

| Setting              | Description          |
| -------------------- | -------------------- |
| Slope Check Distance | Slope raycast length |

Higher values:

* Detect slopes earlier

Lower values:

* Create tighter slope checks

Recommended Range:

```
0.4 – 1
```

***

## Wall Check

The Wall Check section controls wall detection behavior.

This system is required for:

* Wall Slide
* Wall Jump
* Ledge Detection

***

## Wall Check

### WallCheck

Transform used for wall detection.

| Setting    | Description              |
| ---------- | ------------------------ |
| Wall Check | Wall detection transform |

Position this around the player's chest.

***

## Wall Distance

Controls the wall detection raycast length.

| Setting       | Description          |
| ------------- | -------------------- |
| Wall Distance | Wall detection range |

Lower values:

* Require precise wall check placement

Higher values:

* Increase detection range
* May detect nearby surfaces unintentionally

Recommended Range:

```
0.1 – 0.4
```

***

## Wall Layer

Defines which layer is treated as a wall.

| Setting    | Description          |
| ---------- | -------------------- |
| Wall Layer | Wall collision layer |

This layer is used for:

* Wall slide
* Wall jump
* Ledge detection

Recommended:

```
Walls
```

***

## Ledge Check

The Ledge Check section controls ledge detection behavior.

This system is required for the Ledge Module.

***

## Lower Ledge Check

### LowerLedgeCheck

Transform used for lower ledge detection.

| Setting           | Description                |
| ----------------- | -------------------------- |
| Lower Ledge Check | Lower ledge raycast origin |

Recommended placement:

* Near the player's chest

***

## Upper Ledge Check

### UpperLedgeCheck

Transform used for upper ledge detection.

| Setting           | Description                |
| ----------------- | -------------------------- |
| Upper Ledge Check | Upper ledge raycast origin |

Recommended placement:

* Slightly below the player's head

***

## Ledge Check Distance

Controls the raycast distance used for ledge detection.

| Setting              | Description           |
| -------------------- | --------------------- |
| Ledge Check Distance | Ledge detection range |

Recommended Range:

```
0.1 – 0.3
```

***

## Recommended Setup

## Ground Checks

Position:

* Slightly below the player's feet
* Spread evenly across the collider width

This improves:

* Ground stability
* Slope handling
* Edge detection

***

## Wall Check

Position:

* Near the player chest area.

This improves:

* Wall slide reliability
* Wall jump consistency

***

## Ledge Checks

Position:

* Lower check near chest height
* Upper check below the player's head

This allows accurate ledge detection.

***

## Recommended Layers

| Layer  | Purpose               |
| ------ | --------------------- |
| Ground | Floors & slopes       |
| Walls  | Wall & ledge surfaces |

***

## Common Setup Tips

* Keep raycast distances relatively small
* Incorrect check placement can cause unstable movement
* Use Scene Gizmos while positioning checks
* Proper layer assignment is critical
* Ensure wall surfaces are assigned to the correct layer

***

## Notes

* Ground checks directly affect jump reliability
* Slope detection depends on accurate ground normals
* Wall detection is required for ledge mechanics
* Improper ledge check placement may cause failed climbs

## What's next?

{% content-ref url="/pages/ytgu4tH8eZr1V9qiDtZs" %}
[FAQ & Troubleshooting](/pro-2d-controller-doc/getting-started/faq-and-troubleshooting.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://the-code-cm.gitbook.io/pro-2d-controller-doc/getting-started/collision-detector.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
