Platformer: Ladder System (Fixes)

Ryan McCoach
4 min readJan 14, 2022

--

Intro

In this article we fix a few bugs from my previous article on creating a Ladder System below.

https://ryanjmccoach.medium.com/platformer-ladder-system-947e95afa248

Bug #1 & #2 in Action

Bug #1

When the player climbs up the ladder and jumps before the exit animation triggers, the player gets stuck in the air. What is causing this is the player has a animation trigger above it and there is another exit ladder trigger. When these collide as the player is climbing it will cause the ladder exit animation. But, if the player jumps, these two triggers still collide causing a bunch of things to turn off and one being the character controller.

The Fix

We identify the bug is happening during the ladder movement when the player jumps. When this happens we want to turn off the exit trigger using a coroutine, so we prevent the exit ladder animation from playing when it shouldn’t.

We first need to get a handle of the trigger game objects by finding it in the start and completing a null check.

Looking at the coroutine, we set the trigger game objects to false, wait a few seconds and reactive them.

Bug #2

The other bug is when the player climbs up the ladder and moves back down the ladder the player tries moving off of it, the player is stuck in the climb animation and can only move up and down even when they are not on the ladder. What should happen is when the player is at the bottom of the ladder and wants to move off it using the left or right arrow key they can and it will transition back to the run and idle animations.

The Fix

We resize the trigger colliders so they still trigger when they enter and as the player climbs they are still in the collider until it reachers the exit triggers at the top.

But, there is a gap at the bottom where the trigger can exit allowing us to exit the climb animation back to idle/run animations and normal controls.

When the exit trigger happens we check to see if it is the enter box, we grab the player component and call a method from the player.

This method sets climbing ladder to false, which returns normal controls and sets the climb ladder to false.

We just need to make sure we have a transition from the ladder climb back to idle and give it the Climb Ladder bool condition and set it false.

Conclusion

With the bugs crushed this works much better. Debugging can sometimes be a frustrating process, but is an essential part of programming. You need to continuing test to break and if it breaks isolate the problem and fix it. This will allow you to have a better understanding of your code and give you ideas on how to create more elegant code.

--

--

No responses yet