Simple Ladder for Platformer Game

6
  • 68 favourites

Attached Files

The following files have been attached to this tutorial:

.capx

ladder-platform-tutorial.capx

Download now 7.12 KB

Stats

6,889 visits, 13,460 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.

Hi everyone!

I've been looking for a ladder tutorial but never found. So I decided to make one myself!

Also, I'll make a translation for PT-BR later.

1) Getting Started

First things first, make a simple level with Solid behavior and a player. Make it so your player can't jump on those platforms above.

I won't explain how to make a simple platformer, but you can find great

tutorials

on the subject.

2) Player behaviors

Give your player a Platform and 8 direction behaviors. Simply put, we'll activate one and deactivate the other when on ladders and vice versa when not on ladders. Quite simple right?

Check the bold stuff! Those are important!

Directions: Up & Down

Set angle: No

Default Controls: Yes

I'll leave the rest on default, that's really up to you and your game.

BUT! If we leave it like this, it could get pretty buggy, so let's turn that 8 direction behavior off on the start of the layout:

It is important that you "ignore user input" instead of "set disabled".

Also, make sure you don't use the Default Controls on the Platform behavior.

Test it out, but you should be fine!

Don't forget to save! The real stuff starts here!!!

3) Ladder implementation

Let's make a new sprite object called "ladder". Make it thinner than the player.

Now let's start to implement it's functions!

Let's start by giving the player two instance variables: canClimbLadders and onLadders.

Every tick, the game will check the player's status to see if he CAN climb a ladder, setting canClimbLadders to true or false, because maybe in your game there will be some state that you won't want him to be able to climb ladders, like attacking or being hit, I don't know. In our case here, it will always be true.

The variable onLadders will simlpy tell us if the player is climbing a ladder or not.

Okay so let's make our player climb this ladder.

Test it and you can see it's working... kinda. The player only goes up when you press the Up Arrow button and it's pretty glitchy. The secret is in the first Else block.

Let's tune it up!

Okay, now we changed the condition to get out of the ladder by pressing S. We also make the player "snap" to the center of the ladder with the Set X condition. The Platformer vector conditions are there to take care of some bugs, you can find yourself if you haven't already by now.

Also, comments and SAVE IT !

By now you may have noticed that you can't raelly go up the ladder, so what's the point?

That's another simple task:

Geez, but now we can't really get off the stairs - unless we press S - but we should be able to get off the stairs when hitting the floor above or below right?

Notice that I changed the Set Platform Vector X and Set Platform Vector Y placements for optimization.

We are almost ready now! Let's just make the player climb the stairs from above it:

And - with some adjustments - we are finished :)

4) Conclusion

Hopefully the comments make reading the code and understand the logic easier.

This is my first tutorial so please try to bear with me. xD

Leave any questions (or any feedback really) in the comment section below and I'll try to answer it!

Oh and the .capx is there so be sure to download it. :)

See ya!

.CAPX

ladder-platform-tutorial.capx

Download now 7.12 KB
  • 1 Comments

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

    The tutorial was very good. Though a little confusing with the jumping around... but still manageable. This area was the big jump of changes at the end of the tutorial. I appreciate you provided the capx. I did the entire tutorial first, typing everything myself. When I push the down button from above the ladder I start the go down but I can not go all the way down the ladder, It pushes me back up. I have compared my event sheet and your event sheet and they are 100% identical. Curious as to why my version has issues.