Nerd For Tech
Published in

Nerd For Tech

Let It Go — The Ledge, I mean

Objective: implement the possibility to make the character fall from the ledge-grabbing state

With this tutorial, I want to give the player the possibility to let go of the ledge and fall instead of climbing it up. The change should be almost effortless since we already have a logic that takes input to climb up.

We just need to remember that the character stays in hanging position thanks to the brute-force trick of disabling the character controller, and it will stay disabled while the character stays inside the ledge (trigger) collider box.

So, what we need to do is to disable the collider (and re-enable it after a short time for future grabbing), enable the character controller and let the player fall.

R is the key we need to press to let the magic happen. We deactivate the collider and set a trigger parameter that starts the transition from hanging to falling state.

Deactivation and reactivation of the collider are performed in a coroutine using a delay: long enough to allow the player to fall, short enough to make the ledge available again.

The character controller will be safely enabled on falling state enter. This command will be performed every time the character is falling, but that’s not a problem.

Let’s take a look a the result.

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Recommended from Medium

Deployment Processes With Gitlab CI/CD

The Google Design Interview

How to Import Audio Clips in Spark AR Studio

How Git Works

PowerMock: Testing Tool Or Testing Obstacle

NervousText in AR, 25 years later

Proven Ways to Block Websites

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
Daniele Quero, PhD

Daniele Quero, PhD

A professional developer with passion for game developing and skill-growing. A former Nuclear Physics Researcher who changed his life to pursue his dreams

More from Medium

2D Sprite Sword HitBox Setup

Making a RTS game #42: Designing our main menu 1/2 (Unity/C#)

Journal 142 — Unity Project Development, 2.5D Shooter

Switch Statements to the Rescue