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

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.

--

--

--

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

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

Recommended from Medium

CTF: CSA20/Tricky Guess (or why not to use expect)

My 120-day journey to becoming a Unity game developer — Day 30

Unlike You May Think, Every Programmer Do Testing

Our Experience Writing a VSCode Extension

Tutorial Fuzzy Logic Mamdani for Arduino

Tutorial Fuzzy Logic Mamdani for Arduino

Improving Apache Spark processing performance when reading small files

Prime lend customer care number 9679220920//9973862037/Prime lend customer care number…

High Available Task Scheduling — Design using Kafka and Kafka Streams

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.

More from Medium

Creating a Ladder System in Unity — Part 2: Leaving the Ladder.

Using new Unity Engine VideoPlayer and VideoClip API to play video

Organizing object spawning in Unity

An Introduction to Timeline and Simple Animation in Unity