Game Maker – Wall Walking System

For my last game Multi I implemented a system which allowed for my game character to walk on and jump from walls based on collision handling from an article in the SoulHow Assistance Guides. I thought I’d share that Wall Walking System with you.

Assuming:

  • You have familiarity with writing code in Game Maker.
  • You have a basic understanding of writing simple physics code in Game Maker.
  • Your environments gravity pull objects downwards.
  • That you have handled cases where your character can move on horizontal surfaces

The following Wall Walking System allows a character to walk in a variety of different situations that I’ll illustrate and refer to using the following diagram.

Wall-Cases
Wall Cases

On completing this short guide your should have a better idea on how to have your character walk in the following cases:

  • Green Case – Left, Right on Horizontal Surfaces
  • Blue Case – Up and Down Completely Vertical Left Walls
  • Red Case – Up and Down Completely Vertical Right Walls
  • Purple Case – Left and Right on Vertical Ceiling Walls

In addition your character will also be able to jump up, down, right and left in the Green, Purple, Blue, and Red Cases respectively.

A caveat of this Wall Walking System is that it will not work in the corner cases highlighted by the orange lines due to not specifically handling the effect of the assumed environments gravity. Now on to the system!

Room Kings Innate Properties

The system requires a global property for keeping track of the direction our player object is facing to avoid the ‘Moonwalk Case’.

To solve this issue I created an invisible object I called Room King which was added into every level. The Room King held a number of variables including one that kept track of the direction the player was facing whilst jumping so when landing occurs the correct direction can be set.

Create Event

Player Object’s Innate Properties

Create Event

In our objects create event:

The heart of this system are the stick flags. Based on these flags we can identify what state the player is currently in, and can handle a users actions accordingly, as well as update what animation the player object is using.

In addition a ground variable is used to keep track of whether a player object is touching the ground or not so we can know when to or not use the jump animation.

Step Event

In our objects step event:

The Moonwalk Case refers to not recording a direction change of the player after a Catapult has been performed resulting in the player walking in the wrong direction on landing on a surface.

Player Objects – Key Events

Since I intended to use the W,S,A,D keys for moving my character I had to setup these keys as well. Each key event appropriately tracks various variables necessary for the system.

A

A Key Event:

D

D Key Event:

S

The S key was only responsive in Blue, Red and Purple cases.

S Key Event:

W

The W key was a press event key, rather than an event that returned true the whole time the key was pressed because I only want my character to jump when the W was pressed not that he would hop while the key was being held down.

On Press W Key Event:

There it is, the whole system for you!

If you have any questions, or found something thats wrong please let me know in the comments section below!

Leave a Reply

Your email address will not be published.

20 + twenty =