Search Instagram Twitter Facebook Spotify Grid Tag Date Folder Chat Pencil

Ascending and Descending Stairs

Worked on movement up and down stairs today.

This is how stair movement is done in the game. I have a set of “ghost stairs” which are set to be invisible to the player, and consist of a staircase with much smaller steps.

SbjOAnG

The ghost stairs are set to a layer called “ghost” to ensure that they only collide with the player.

In the old version of the game, I would set the player’s mass to 0.2 instead of 1, so that calling up the stairs felt smoother.

However, in this case, the player would get enough momentum that at the top of the stairs, they’d fly off a bit.

stairs_bump

This felt incredibly distracting.

Eventually, after trying a bunch of things, I found I didn’t actually have to change the mass. But there was the problem where if the player was standing on the stairs, they would slide down, because gravity was being applied. If I took out gravity, then the player would fly off at the top.

The solution was to only apply gravity when the player was moving. Thus, if you remain stationary on stairs, no gravity is applied, and therefore you don’t slide down. But if you’re moving, gravity is applied, and this prevents you from flying off the top of the stairs:

stairs_bump_fixed

The new stair movement system is much smoother.

Here’s the old version:

walking-up-stairs-old

Note how bumpy it is, especially when moving up.

Here’s the new version:

walking-up-stairs-new

Much smoother!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.