> For the complete documentation index, see [llms.txt](https://malbersanimations.gitbook.io/animal-controller/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://malbersanimations.gitbook.io/animal-controller/main-components/manimal-controller/states/ledge-grab.md).

# Ledge Grab

Updated for 1.5.3

## Ledge Grab

**State ID:** 8

The **Ledge Grab** state quickly climbs a flat ledge. It raycasts ahead, finds valid ledges, then plays a climbing animation.

One state can contain multiple **profiles**. Each profile has its own animation, height, and detection settings. Use profiles for grounded, jumping, or falling approaches.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F5xFITNrQr6v6NMIJssiF%2FUnity_CeFxzctzGO.gif?alt=media&amp;token=76a662a8-76e0-4825-b17e-8e15b78dcfa4" alt=""><figcaption><p>Climbing Edge with different profiles</p></figcaption></figure>

## Creating the state

Create a **Ledge Grab** state in either way:

* Select **+** in the animal's **States** list. Then select **Climb → Ledge Grab**.
* Duplicate an existing **Ledge Grab** state asset. Add it to the animal's **States** list.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FPeS1bJkMQYOMKRX0FiVN%2Fimage.png?alt=media&amp;token=38f7032c-30cd-4f1e-8560-b720da0aeb2a" alt=""><figcaption></figcaption></figure>

## Priority

Set this state above [**Idle**](/animal-controller/main-components/manimal-controller/states/idle.md), [**Locomotion**](/animal-controller/main-components/manimal-controller/states/locomotion.md), and [**Fall**](/animal-controller/main-components/manimal-controller/states/fall.md). Set it below [**Death**](/animal-controller/main-components/manimal-controller/states/death.md).

States use priority. Give [**Jump**](/animal-controller/main-components/manimal-controller/states/jump.md) or [**Fly**](/animal-controller/main-components/manimal-controller/states/fly.md) a higher priority to interrupt ledge grabbing.

## How it works

The state casts rays ahead of the character to find a ledge. Target colliders must use the **Ledge Layer**. They can also match the optional **Ledge Tags** filter.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FRrSZDoKJYEKJioXFevw1%2FUnity_w0dIKBBB1w.gif?alt=media&amp;token=990a61d5-9489-4186-b178-984f17d4c0cc" alt=""><figcaption></figcaption></figure>

### Detection rays

| Ray                | Color  | Condition          | Purpose                                          |
| ------------------ | ------ | ------------------ | ------------------------------------------------ |
| **Top / Forward**  | Green  | Must be **clear**  | Confirms no obstacle exists at ledge-top height. |
| **Ledge (Down)**   | Red    | Must **hit**       | Finds the flat top surface.                      |
| **Wall (Forward)** | Yellow | Must **hit (red)** | Finds the vertical wall below the ledge.         |

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FiA56AEYyROExlnq15DKe%2Fimage.png?alt=media&amp;token=15e00683-fad2-437b-8d72-2d136768b57a" alt=""><figcaption></figcaption></figure>

The state can activate when the top ray is clear. The down and wall rays must hit valid colliders. The top surface must be within **Min Terrain Angle**. The wall must exceed **Wall Front Angle**.

### Ledge size validation

Detection can find ledges that are too small to stand on. An optional footprint check rejects thin poles, small blocks, and stacked boxes.

Leave **Min Ledge Depth** and **Min Ledge Width** at `0` to disable this check.

| Ray                 | Color   | Condition         | Purpose                                                 |
| ------------------- | ------- | ----------------- | ------------------------------------------------------- |
| **Depth floor**     | Magenta | Must **hit**      | Confirms the ledge extends back by **Min Ledge Depth**. |
| **Depth clearance** | Green   | Must be **clear** | Rejects walls behind the ledge lip.                     |
| **Width** (×2)      | Orange  | Must **hit**      | Confirms the ledge width meets **Min Ledge Width**.     |

**Effective value = Global + Local.** Depth and width each have a state value and a profile value. The footprint check uses their sum.

## Activation methods

### Input

The state activates when its **Input** is pressed, and the rays find a valid ledge.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F61m1Xk4hV7zpOczpiVM9%2Fimage.png?alt=media&amp;token=4ddcc57b-5eb9-488b-8f10-05606ce2e20b" alt=""><figcaption></figcaption></figure>

### Automatic

Enable **Automatic** to activate as soon as a valid ledge is detected.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FsUoGylOdbip3d7jhGNiS%2Fimage.png?alt=media&amp;token=5b481d43-b287-4dc9-b365-a3f390d1e9fc" alt=""><figcaption></figcaption></figure>

### Automatic by state

Use **Automatic By State** to make ledge grabbing automatic during selected states. Examples include **Climb**, **Jump**, **Fall**, and **Swim**.

### Zones

A Zone can force the state to try activation.

### Reactions

Animal Reactions can activate the state from code or events. See [**Reactions**](/animal-controller/main-components/reactions.md).

## Exit conditions

The state exits when the active profile reaches **Exit Time**. This value uses normalized animation time.

The state then calls `AllowExit()`. Lower-priority states can activate. The character returns to **Grounded**.

## Animator setup

Use a sub-state machine for Ledge Grab animations.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FLAK4kJz6BiFXin8CrBdN%2Fimage.png?alt=media&amp;token=f379c466-da03-4db5-af38-5bb661e13932" alt=""><figcaption><p>The Transition Enter Condition of this state is State=8</p></figcaption></figure>

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FvfqYjdb7VeksfD9II589%2Fimage.png?alt=media&amp;token=a487e6ef-4763-4350-baaf-10db667452ae" alt=""><figcaption></figcaption></figure>

### Transition duration

Use **State = 8** for the transition into the sub-state machine. Keep its duration short. The default is **0.1 seconds**.

{% hint style="danger" %}
**Align Offset** is tightly coupled to the transition duration. Update it when the duration changes.
{% endhint %}

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FFFX517YeHW7slZursHkv%2Fimage.png?alt=media&amp;token=8bd39f67-bae0-4f32-9744-10a8246412fa" alt=""><figcaption></figcaption></figure>

### Core animation

Tag every core animation with the state ID name: **LedgeGrab**. The **Enter Status** value selects the profile animation.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FOJvHFk6kCbbCTL4KzaSF%2Fimage.png?alt=media&amp;token=20d4227a-8784-40da-bdc1-cda10f543dc8" alt=""><figcaption></figcaption></figure>

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FQ9pPPof39nGsGdCAiz2b%2Fimage.png?alt=media&amp;token=033e6080-ec6e-42df-97f0-0aafab8dc773" alt=""><figcaption><p>Value of the State Enters Status Parameter on the Animator</p></figcaption></figure>

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FS6zJClpagdgYBwtTSSXF%2Fimage.png?alt=media&amp;token=e06b8b87-a77f-40c5-84a0-edf48e1e6fb3" alt=""><figcaption><p>Value of the Enter Status on the ProfileState</p></figcaption></figure>

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FiPUVJi5QEEF4v7Nb6D6I%2Fimage.png?alt=media&amp;token=a6654a3f-becf-4124-a01d-975a235e344e" alt=""><figcaption></figcaption></figure>

## Configuration tabs

### General

Basic state settings shared across animals.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FP8S8gR82YQgPEhJ5DVOs%2Fimage.png?alt=media&amp;token=7db740ce-727c-4e78-b364-e67bc7b75c8d" alt=""><figcaption></figcaption></figure>

### Tags

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F1i0LY8L4HkHc9vp1BPiG%2Fimage.png?alt=media&amp;token=54c8fbe4-0e8c-46c8-a12e-36695c25108e" alt=""><figcaption></figcaption></figure>

Enable **RootMotion**, **+Rot**, **+Pos**, and **Ignore Lower States**. Disable the remaining modifiers.

The character is not grounded during this state. Gravity and ground orientation are disabled.

### Limits

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F4asuK0X4qTYHOFq6LK2C%2Fimage.png?alt=media&amp;token=e9260237-3f5f-4b05-8684-98edad113d82" alt=""><figcaption></figcaption></figure>

Disable the state for selected character states, modes, or stances. For example, disable ledge grabbing while swimming underwater.

### Speeds

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FGZCBTjCHi3p1qC2uHvbV%2Fimage.png?alt=media&amp;token=bab44b8b-049c-41f7-bb1e-cbec5b1514ad" alt=""><figcaption></figcaption></figure>

No speed modifiers are required. Root motion or profile curves drive all movement.

## Ledge parameters

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FMri8jGtBRvoghmvNHBdv%2FUnity_2KLWhXZPq6.png?alt=media&amp;token=db7ac99f-a21a-420a-b0d2-4daddbec8560" alt=""><figcaption></figcaption></figure>

### Ledge Layer

Layer used to identify climbable surfaces.

### Ledge Tags

Optional tag filter. Only matching collider tags count as ledges.

### Automatic

Climb automatically near a valid ledge. No input is required.

### Automatic By State

States during which Ledge Grab behaves automatically.

### Kinematic

Sets the character Rigidbody to kinematic while active. This prevents colliders interfering with the ledge.

### Disable Main Collider

Disables the Main Collider while active. It is restored on exit.

### Wall Distance

Target distance between the character and the wall.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FbFfETgOZ9o5KGo0qMRhQ%2FUnity_RPh66Ofhz2.gif?alt=media&amp;token=bcc7a726-0432-4a9d-a1c3-987d197e3a04" alt=""><figcaption></figcaption></figure>

### Wall Front Angle

Minimum angle between the wall normal and character forward required for activation.

### Min Terrain Angle

The top surface must be flatter than this angle.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F5DOaxfEzF6yUxCaDfF5n%2Fimage.png?alt=media&amp;token=83bd1a87-e0f0-489f-97c7-ff4c660e2fab" alt=""><figcaption><p>angle 35 wont activate the state if the value of Min Terrain is lower than 35</p></figcaption></figure>

### Forward Length

Global distance for the green forward detection ray.

### Wall Checker

Vertical offset below the ledge that confirms a wall exists.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FQIwLLIlpWteyBIR4jTLE%2FUnity_kjjViloMC0.gif?alt=media&amp;token=468b1f09-b167-492d-b9c4-8254839accf3" alt=""><figcaption></figcaption></figure>

### Min Ledge Depth

Global minimum depth behind the ledge edge. This is added to each profile's local value. Set `0` to disable the global depth check.

### Min Ledge Width

Global minimum sideways width. This is added to each profile's local value. Set `0` to disable the global width check.

### Hit Transform

Name of a child transform that stores the ledge ray hit point. Use it for UI or aiming.

### Update Hit Transform UI

Updates the **Hit Transform** during every check. Enable it only for UI or aiming, as it adds raycasts.

### Add Hit Transform To Aim

Uses the **Hit Transform** as a temporary Aim target while a ledge is detected.

## Profile settings

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FzAg4yaWyxawQb5sae1i5%2Fimage.png?alt=media&amp;token=df4a44f9-18e6-493d-a9a0-1f0a8d300160" alt=""><figcaption></figcaption></figure>

### Name

Profile identifier.

### Enter Status

Animator **Enter Status** value that selects this profile's animation.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F5xFITNrQr6v6NMIJssiF%2FUnity_CeFxzctzGO.gif?alt=media&amp;token=76a662a8-76e0-4825-b17e-8e15b78dcfa4" alt=""><figcaption><p>"Ledge Grab" has a Enter Status of 0 and "Step Up 1 Meter" has Enter Status of 1</p></figcaption></figure>

### Max V Speed

Maximum vertical speed for this profile to be checked. Use `0` to ignore speed.

### Last State

Only checks this profile when the selected state was previously active.

### Check Upwards

Casts an upward ray to confirm no roof or overhang blocks the ledge.

### Only Grounded

Only checks this profile while the character is grounded.

### Forward Multiplier

Local multiplier for the global **Forward Length**.

### Height

Vertical offset of the green forward ray.

### Ledge Exit Distance

Length of the red down ray that finds the ledge top.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F7rnalX6HM59KwH4H5HMq%2FUnity_jsUPVQQz4C.gif?alt=media&amp;token=2ed17539-7dd4-4de3-8c25-f88c04fe785c" alt=""><figcaption></figcaption></figure>

### Min Ledge Depth

Extra depth added to the global **Min Ledge Depth** for this profile.

### Min Ledge Width

Extra width added to the global **Min Ledge Width** for this profile.

### Exit Time

Normalized animation time that calls `AllowExit()`. The default is `0.9`.

### Align Offset

Horizontal (X) and vertical (Y) alignment offset. Use it to align the character with the ledge.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FpPmvwq0WDzDqHPENcheV%2FUnity_oesD78DNiD.gif?alt=media&amp;token=f8ca7279-84e7-4b42-880c-25af85cc8dbe" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
This value is tightly coupled to the Animator transition duration.
{% endhint %}

### Orient

Faces the character perpendicular to the wall normal.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FRedF9wnVCwGp3TewMyEs%2FUnity_YtlOT18Hen.gif?alt=media&amp;token=0df41065-5a0c-4595-be0d-8b415811b4b4" alt=""><figcaption></figcaption></figure>

### Orient Smoothness

Smoothing speed for orientation to the wall.

### Additive Position

Adds procedural movement when the animation has little or no root motion.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FGfajiLR597M8neo1oY0R%2Fimage.png?alt=media&amp;token=6228531a-8afb-4e60-b435-e2182e83fba4" alt=""><figcaption></figcaption></figure>

### Height Speed

Magnitude of the additive vertical push.

### Forward Speed

Magnitude of the additive forward push.

### Height Curve

Scales the vertical push over the animation.

### Forward Curve

Scales the forward push over the animation.
