Nerd For Tech
Published in

Nerd For Tech

Climb down the Ladder

2.5D Game Development

Objective: Allow player to move down the ladder.

First add a cube and set the trigger inside the collider component to true.

Then add a enter location which will be used to transform the player position to show the effect of player shifting to climbing position to start moving down.

Then add a script to the collider and inside the script, create a trigger function which will call a Climb Ladder Down function while providing the enter position.

Then the called function inside the player script will set the on ladder to true to enable the condition for climb, add the enter position to global variable to be used later and set the climb direction to down by setting to down bool variable to true.

Now when the player presses S key then disable the on ladder condition and set the climbing to true to disable player movement while calling the climb long ladder down function.

Inside the called function, set the climbing animation to true and move the player to the climb down position while setting the player rotation so that the player always faces the ladder when moving down.

Then add another collider at the bottom which will disable the animation and enable the movement.

Add a new script to the bottom collider and inside the script, call the ladder bottom exit function when player enters the collider i.e. reaches the ladder bottom.

Then inside the player script and inside the ladder bottom exit function, disable the animation, set the on ladder to false, climbing to false to allow movement and to down to false so that player moves upwards next time.

And this is the final result.



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