Walkable Stairs w/ Gravity Flip Switch Tutorial (mbStairs + mbGrav)

Favourite 9 favourites
Tutorial written by ZebbiOriginally published on 11th, February 2015 - 2 revisions

This tutorial will show you how to have a character walk upstairs by holding the ↑ on approach, as well as when landing on the stairs. It will also show you how to treat the staircase like a jump-through platform when walking on the adjacent floor.

Setup Platform Character

We will be using a player container with pinned animations, as is standard with platformer games.

Here is our character positioned over a separate fucia container object:
Now we lay them directly over the top of each other:
And here is our events to control platform movement, as well as a couple of layout-related actions:

As you can see, we have actions to deal with mirroring for walking directions, as well as upside-down angles for the gravity switch.

Setting up the stairs

Draw a 1px diagonal line, point a at the bottom pixel of the image, and point b and the top right, so you have a staircase line running from lower-left to upper-right:
Now make a collision poly that is basically 2d and runs exactly alongside it:
Clone this stair and mirror it in the animations editor so that the image and the collision are flipped:
Add these both to a family called "steps":
Give this family the "solid" behavior:

Gravity switch

Now, draw a gravity switch, ala Mario, with a separate animation for the depressed switch:

Add a global instance called "GravTime":
Open full size image

And write the gravity-switch events like so:
Open full size image

This will turn our gravity upside-down for 5 seconds, and then turn it off, (with the animations to match outlined in our first set of events)

Setting up the stair events

Now we have gravity in place, here are the events for our stairs: The ternary operator is testing if gravity is switched or not, and the outcome with decide if we should check for 1px below (ground level on normal gravity) or 1px above (ground level for upside-down gravity). The sub-events will take care of holding-down ↑ to walk up the stairs if we are on the ground. The second condition will check if we are falling or jumping whilst over the stairs; if falling, we shall land on them and if jumping we shall jump-through them.


And that's all there is to it! Please comment with any suggestions or ideas you have to improve on this :D

Unlock your full gamedev potential

Upgrade to the Personal Edition of Construct 2, it has way more features and won't holding back from making money and using your full creativity like the free edition does. It's a one off payment and all Construct 2 editor updates are free for life!

View deals

Plus, it's got a lot of additional features that will help you save time and make more impressive games!

Congratulations on finishing this tutorial!

Did you learn a lot from it? Share it now with your friends!

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.