Devlog #2: Stairs, stairs, stairs


This week’s journey into game development took me into the realm of stair mechanics within my 2D game engine. On paper, it sounds straightforward: make stairs that players can actually use. But as any good engineer knows, the devil is in the details.

The goal was to create stairs that not only look part of the world but also interact seamlessly with the player’s commands. It’s akin to programming your thermostat: it seems simple until you’re four hours deep into the user manual.

I’ve already implemented ladder climbing logic using sensors, but I decided to look into some tutorials anyway. That led me down a rabbit hole of platformer games, which were about as useful for my problem as a chocolate teapot. However, one Unity tutorial showed a similar way as my ladder logic of using sensors in the top and bottom.

After a few iterations and more coffee than I’d like to admit, I arrived at a working solution.

Let’s unpack the mechanics:

  1. Initial Check: A piece of code determines if player position is below stairs middle point and disables the stairs. That way player can always run through the stairs by default, like a ghost

  2. Indication: As the player approaches the sensor, an arrow appears, signaling that the stairs are within reach, akin to a polite nod from the stairs themselves.

  3. Activation: The player presses up, and the stairs solidify, allowing for collision and ascent. The arrow turns green as if to say, “All systems go.” Also a temporary block for the piece of code has been set to not change collision filter.

  4. The Climb: Once the player begins their ascent, the stairs remain solid, thanks to a check that confirms the player’s intention to climb.

  5. Continuation: Next stairs go the same way, player activates them and starts climbing. The top floor bit is also considered as stairs, so it’s not activated until player is above it.

  6. Descent: For going down, player presses down when on the stairs bit of the floor and the floor deactivates. Stairs deactivate automatically after halfway bit.

There it is: stair mechanics demystified and implemented. It’s a bit like explaining Wi-Fi to your grandparents—complex to describe but magical in action.

Have any clever tricks or feedback? Feel free to drop a comment below!

Stay tuned for more tales from the coding front. Thanks for joining me on this adventure through game development’s ups and downs—quite literally this time!

Leave a comment

Log in with itch.io to leave a comment.