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

Find the best position for the ledge grab action.

Rusben Guzman
2 min readMar 23, 2022

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.

--

--

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.