How to set up a ledge grab system for platformer in Unity

Let’s go over how to add a ledge grab system to the platformer project.

I am continuing to add to the Player script from this article. Animations in the article are from

First, add a collider to the player which will be used to detect ledges. Set the collider to IsTrigger and the tag to “Ledge”:

On the platform, add a similar collider together with a RidgidBody:

Add two more boxes to the platform. One for where the player will have the feet while holding on to the ledge and another for where the player will stand after climbing up:

Create a script called LedgeGrabber and attach it to the collider on the platform:

Open the Player script. Add a bool to check if the player is currently grabbing the ledge. Also add a Vector3 for the position of the player after climbing up:

In the PlayerMovement function check if the E key is pressed while the player is grabbing the ledge and if so, trigger the climb animation:

Create two public functions, one for handling the ledge grab and another for handling the climbing:

Open up the LedgeGrabber script. Add two serialized Transforms for the positions. Add an OnTriggerEnter function, and if the ‘Ledge’ object on the player is detected set the player’s position:

Open up the Animator window and set up the animations as shown in the screenshot below:

Select the Climbing animation state and add a behaviour:

Open up the behaviour script. In the Exit event call the SetClimbUpPosition on the player:

Lastly, drag the transforms on the platform onto the LedgeGrabber script on the inspector:

Good luck!




Unity / C# Game developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Blog Update: “Testing Bits: 372 — Dec 20th — Dec 26th, 2020”

Scaling the serverless summit requires environmental sympathy with dev & ops

Juptember into Moontober

Real options and refactoring

Lithium Product Update

Accomplishing the Hackathon Pentafecta

Web Scraping with Java (Jsoup).

SpringBoot — YAML configuration

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Niklas Bergstrand

Niklas Bergstrand

Unity / C# Game developer

More from Medium

Qatar: Rights groups slam ‘arbitrary’ travel bans against four citizens

vEmp and Babylons partnership will accelerate growth in the BSC chain meta-universe

DodoDial Sprint 2 (Medium Fidelity Prototype and Demo Presentation)

Let there be light: Ensuring visibility across the entire API lifecycle