Creating A Ledge Grab in Unity — Part 2: Stop player movement on ledge collision.

Simulate ledge grabbing

Rusben Guzman
Mar 21, 2022

Objective: detect the collision between the ledge checker and the ledge and stop the player movement.

In the animator controller attached to the player I added a new animation for the hanging action and a bool parameter to make the transition.

In the player controller I created a new method to trigger the hanging animation and disable the character controller component. By disabling this component we stop the player because it controls the gravity and movement.

In the ledge grab checker script attached to the ledge checker in the player we have to use the OnTriggerEnter function to detect the collision, then we check for the ledge tag and call the GrabLedge function in the player script.

And that’s it. Now the player detects the ledge and stops its movement.

--

--

Rusben Guzman
Rusben Guzman

Written by 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.

No responses yet