Ladders and Static Platforms


Hello there!

Past week I've been working on fixing a rough implementation I made to allow the Platform Actor to have a more complex interaction with the environment. This includes a Climb state, so it is able to climb ladders, and the possibility to jump and fall through platforms. So let's talk about that!

Climb&Ladders

The ability to climb ladders was always on the roadmap, but since a request was made I decided to dedicate a full sprint for this.

The implementation is very simple:

  • Ladders are objects with a top and a bottom part
  • Top part is a StaticBody2D meant to behave as a floor
  • Bottom part is an Area2D meant to allow the actor climb
  • The whole thing is inside a special CollisionLayer
  • The Platform Actor has a special Area2D that checks for collisions in the said CollisionLayer (the ladders layer)
  • Once it detects a ladder, it allows the Platform Actor to perform a climb
  • When the player presses UP or Down it enters in the Climb state, and stop searching for collisions in the ladders layer
    • This allows the actor to pass through the top part of the ladder
    • The Area2D that checks for collision on the ladders layer acts as a buffer, it still searches for collisions there and tell if the character is still climbing a ladder or not
  • When touching a floor, jumping or moving out the ladder's area, the character gets out the climb state

The result is the following:

Note that the shapes used in the ladders are just mockups, you can use any kind of shape, the important part is that the StaticBody2D and the Area2D are inside the ladders layer, which is the one the Platform Actor's checks for collisions.

Pass Through Platforms

This one is very similar to the above approach, it basically uses another collision layer and also sets the platform's Shape2D to be one way collision (allowing both to jump through it from bottom to top and to fall from it from top to bottom).

I even created a very cool tutorial for this one past week, check it out in the Tutorial - Pass Through. The result of this approach is the following:

Well that's it for this week's devlog! Thanks for supporting, keep developing and until the next time!

Get Pigdev's Platform Template

Pre-order Now$15.00 USD or more

Comments

Log in with itch.io to leave a comment.

(+1)

LOVE IT!