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

1
• 9 favourites

### Attached Files

The following files have been attached to this tutorial:

.capx

### Stats

2,712 visits, 3,941 views

### Translations

This tutorial hasn't been translated.

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":

And write the gravity-switch events like so:

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.

### Postscript

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

.CAPX