Ladders

Obj: ladder

First create a new object ladderIt has no events/actions.

OBJ: character

Step event

Go into your character object.

In the Step event you already have and start by adding the following actions at the end:

  • Comment: "check if on ladder"
  • Check Object: object 'ladder', (0,0), rel.
  • Add start & end blocks

Inside the Start & End blocks add:

  • Set Gravity: direction 270, gravity 0
  • Set Variable: variable "vspeed", 0
  • Change Sprite: sprite = characterClimbing

You should now have all these actions at the end...

Up event

Go into the <Up> event. When the character is at a ladder, the up arrow key should move it up, rather than jump...

Before all actions, add:

  • Check Object: object ladder, (0,0), relative
  • also add Start & End blocks
  • Add Else and start & end blocks around what you already have

Then inside Start End blocks at the top (if on ladder):

    • Check Empty: is there anything just above?
      (0,-3), only solid, rel.
    • Jump to Position: If there isn't, move it up a bit
      (0,-3), rel.

So your <Up> event should now look like this...

Down event

We'll do similar actions in the <Down> event...

  • Check Object: object 'ladder', (0,0), rel.

Go into Check Empty and Jump to Position actions and change the Y values from "-3" to "3". Checking if anything just below? If there isn't, move it down a bit.

Room

Add the ladder object and a platform for the character to step off onto at the same height.

When you test it out, your character should change as soon as it touches the ladder; the Up/Down arrows should make it climb up and down, and you should be able to step off onto the top platform.