Creating a Ledge Grab System (part 3)

Snapping in place and Pulling your character up.

Now that we have our hanging animation in place we need to set up the position so it doesn’t look like our player is hanging in mid-air. To do that we will need force the position to the player so it snaps in a desired location when hitting the edge.

Scripting the Snap:

In the ledge script we need to make an serialized field variable to handle the vector3 position we want for our player to snap too. We need to serialized it so we can access this data within the Inspector for ease of adjustment later on.

Next we need to force the placement of the player only when the player collides with the ledge checker, so within the IF statement under the On Trigger Enter method, we will add a the ledge position variable we just created earlier.

In the player script we need to apply the ledge position in the public method by using Vector3.

Then we add the forced position within the method, by using Transform.position = _LedgePos.

Now we will snap to once place when our colliders make contact.

Adding an Extra Animation:

As an extra step, I personally decided to add in an extra animation during the jumping and ledge hang, and that is the bumping of the character when making first contact.

I used another animation aided by Mixamo, which I downloaded and imported to the Animator.

In the Animator, I used the jumping to hanging animation before the actual hanging animation. I set the conditions that used to belong to the hanging state to the Jump to hang state. Then the Hanging state is just a non-condition transition. Just make sure that the jump to hang is not set to loop, since we only want to happen once then transition to the hang.

The end result should look very smooth, if you find that the position is slightly off, adjust it within the Ledge checker where we set the Vector3 variables.

The end result should look like this.




A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

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

Recommended from Medium

Announcing the Release of Neo4j GraphQL Library 2.0.0

Kubernetes DevOps Tip #5: Why Setting imagePullPolicy to Always is More Necessary Than You Think

My Second Coding Test for Internship

How do I apply a sample time to an array of values that represent data points at different times?

Django-REST User Level Permissions and Object Level Permissions

Using Nested Routers DRF-Nested Routers in Django Rest framework

Weak and unowned keywords in Swift

Coding & Hardware Books Bundle

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
Simon Truong

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

More from Medium

Creating the Main Menu

Easy Way to Make an Audio Slider

Level Design in Unity Part 2: The Walls

New Input System and UI