A Simple Method for Climbing Ladders in platformers

4
  • 41 favourites

Stats

8,796 visits, 14,068 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

The Goal - Platformer Ladders

The goal of this tutorial is to provide you with, and explain the functionality of, a simple solution for creating climbable ladders in Construct 2 for use in platformers.

Although Construct 2 provides many predefined movement functions I have yet to find one for climbing ropes and ladders, and the solutions I have found have been complex and rely on variables and multiple objects.

This solution requires two objects; the player object and the ladder, and a relatively simple event block (technically a third object is required, but this is just the player image.)

The sprites in use are free sprites provided by YoYo Games.

Prerequisites

I want to keep this tutorial as simple as possible, so I'm going to assume knowledge about the events sheet and all the basics of making a game in Construct 2. If you've been through the first tutorial and the beginner's platformer tutorial you should be fine, though the next platformer tutorial would also be a good idea.

I'm using the free edition of Construct 2, release 132.

The Setup

The Player

First things first get a room set up and create your ladder and player objects. Remember that for a platformer it is best to create a rectangle shape as your player object and pin the player image to it.

Next I gave the Player Object (the rectangle) platformer movement and set Default Movement (under Behavior>Platform in the instance properties pane) to no. This is because as standard Up makes the player jump, and we want up to move up a ladder instead. This can be amended, if you want jump to climb that can be done to, I just prefer it this way.

The Ladder

I have created a ladder object using an image of the bottom portion of the ladder.

I then went into the animation for the ladder and added a middle of ladder and top of ladder image as new frames:

By doing this I can make the ladder any length I like by simply changing the Initial Frame of each instance (under Animation in the instance properties pane) as needed.

This means I can make the ladder look the way I want while still being able to reference the whole thing as a single object.

The Events

I've applied my events to a separate, Controller event sheet, this way I can attach it to any level.

Movement

Firstly I added basic platform movement using the Simulate control function:

All I want here is left, right and jump. As I stated earlier you can also keep the jump function attached to the up button and have jump climb the ladder.

Climbing

Next I added the climbing event block. This is a bit bigger, and makes use of the Else statement to keep it as simple as possible (to use the else statement click within the condition block and select Add...>Else, if you don't add an extra condition to the else statement it will account for all other situations)

So the block basically says this:

    IF Up is pressed & Player is on Ladder
          THEN Climb Ladder
    ---ELSE
    IF Down is pressed & Player is on Ladder
          THEN Descend Ladder
    ---ELSE
    IF No button is pressed & Player is on Ladder
          THEN Sit on Ladder
    ---ELSE
           Reset gravity to room normal


The event makes use of the Set gravity feature, which with a platformer movement object would normally pull the object to the ground when it is off the ground. By setting the gravity to 0 we can move up and down the ladder without falling.

We need to use the final ELSE statement to reset the gravity to room normal so that the object falls as normal in any other circumstance. We could use a temporary variable but I wanted to avoid variables for this tutorial.

Conclusion

So we now have a working ladder function, by simply stepping away from the ladder the player will fall as normal.

I'm sure there are other methods, but this works well for me. Have you had success with other methods of ladder climbing?

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!