Creating A Ledge Grab in Unity — Part 3: Snap player in the ledge position.

Objective: move the player to a specific position after detecting the collision.

In the last article we detected the ledge collision and stopped the player movement but now we want to move the player to make the hand of the player match with the ledge.

First we have to play the game, go to the ledge and move the player to the desired position. Then we have to create a new empty GameObject just to save this position in the transform component.

Next we have to create a new C# script and attach it to the ledge.

In the ledge script create a new variable to save the snap position and a function to return this position.

Then in the ledge checker script we assign the new position when we detect the collision with the ledge.

And that’s it. Now the player grabs the ledge and is in the correct position.



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
Rusben Guzman

Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.