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

A Tale of Plates(Rust Programming Language)

CSS CHANGED MY LIFE in 2020..with its power of simplicity and animating make me drown within..

Secure your Azure Web App for FREE and say goodbye to HTTP in just a few minutes

Why Spinnaker and Kubernetes Work Better Together for Continuous Delivery

Persistent sessions in the Oracle cloud made easy

Thinking in Big Data at Rapido: Cohort KPI

GraphQL introspection and introspection queries

5/9 web hacking daily log

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

A year ends, a new roadmap begins

The Rewards and Virtues of Writing Flash Prose

Eliena: Hi @MorrisDXplorer @leslieapongol

Happy Thanksgiving ❤❤❤ Weekly NishIsHere! — Issue #25