How to Make a Responsive Action Platformer

Let’s say that you have a great idea for the next big platformer title. You already have the levels floating around your head, the story is engaging and the gameplay is what gamers will rave about.

You have planned:

  • Expert-level platforming level design ✔
  • Intelligently crafted AI that really makes you think ✔
  • A relatable main platforming protagonist that everyone will love ✔

The only thing you’re missing is expertly-crafted, fine-tuned controls. We already have a great article about upgrading GB Studio’s Platforming Engine, which will help you with coyote time, mid-air deceleration and jump buffering. All of these are great features to have, especially to ensure that players are having fun with your game and aren’t required to have pixel-perfect jumping abilities. In this article, we’ll add some additional tools to your arsenal beyond those to help players really connect with your game and ease them into the platforming requirements you’ve set for them.

Moves like Mega

One of the most memorable things about the Mega Man series is the iconic jump physics. There’s something to be said for a character who not only looks ridiculous while jumping, but still offers you tight controls to ensure you hit the mark each time you jump. With spikes, enemies, and all kinds of obstacles littering each level, the Mega Man games are iconically hard, but also respectable in how they presented your task. It was up to you to figure your way through the levels despite the odds. One thing that Mega Man had that GB Studio’s platforming engine does not is the ability to turn around mid-air.

Mega Man 2 is known for its quick, twitchy controls

In GB Studio, if you jump up and go to change to the other direction, you will find that you are stuck with whatever direction you were facing before you made the jump. This is less than ideal, and could really frustrate when a player is trying to face an enemy to get some hits in. Luckily, this is an easy fix that doesn’t require any engine modification, and it can be placed in your [On Init] event on any scene you intend to use it.

Fixing a Sticky Situation

The reason I initially decided to add this to my game was due to a boss fight against a boss called the “Dreamweaver.” The Dreamweaver is a huge spider hanging from the ceiling, and you must use webs to bounce up and hit him. When you bounce up from the webs, you are stuck in the direction you bounced from, which often leads Nemo to be facing the wrong direction:

Bouncing on a web and trying to hit the boss, but facing the wrong direction.

Modifying the input setup to allow you to turn around after the jump makes a world of difference:

Bouncing on a web, Nemo is able to switch directions and hit the boss.

Seems simple enough, right? So how is it achieved? Let’s get into it!

Adding the Horizontal Flip

Start by adding an [Attach Script to Button] event to your [On Init] script (make sure the checkbox for “override default button action” is unchecked). From there, select the Left and Right buttons to initiate this script, so whenever either one of them is pressed it will activate it. Next, add an [If Joypad Input Held] script to the “On Press” part of the ‘Attach’ script and select the Left input first. Within the Left’s ‘True’ section, add a [Set Actor Direction], click the drop down menu to select the Player, and select Left. This will allow the player to turn left if the jump was initiated facing right.

To finish the script, add another [If Joypad Input Held], but this time inside of the ‘Else’ section (click on the right-facing arrow next to ‘Else’ to open it). Go ahead and set this one to Right, and in the Right ‘True’ section, add another ‘Set Actor Direction’ with the Player selected, and set it to Right.

Adding our “Flip Script” to On Init on our scene

With that all set up, GB Studio will now recognize that we pressed the opposite direction in the air, and switch accordingly! Another cool feature is that switching your direction retains a bit of the X or side-to-side velocity, so it also provides players some of what is commonly known as “Air Control,” which is good for allowing additional, split-second decision-making in the air.

Attacking Any Which Way

An unexpected, yet welcome feature is that you can now jump and use a projectile attack in whatever direction you are facing in the air. All you need to do is make sure you change your ‘Direction’ to Player in the ‘Launch Projectile’ settings.

Adding a Launch Projectile to our script. Make sure to select ‘Player’ as the Direction of your attack!

Once this is set, it will also work for long-range attacks, as it will only shoot them in the direction the Player actor is facing. What if you want to have a melee attack flip as well? We’ll cover that next.

Flipping Attacks like Crazy

In most situations, when you’re creating a melee attack in GB Studio, you use an Animation State to switch your player to look like they are attacking. If you don’t and end up using a Launch Projectile script, you’ll find that if you don’t set the Life Time to almost instant, your attack just stays lingering in the air from when you pressed the button. Pretty odd looking.

The solution to this problem is a two-step fix. First off, using a custom Animation State as we mentioned, but combining it with an invisible Sprite Sheet like this one:

An a Launch Projectile event, it will allow you to fake the attack and do all the dirty work behind the scenes. Now that you have that setup, you’ll find that if you do your horizontal flip in the air after attacking, you will never hit the enemy.

The reason why is that your Projectile attack will only work in the initial direction facing. To rectify this, we’re going to add a little bit more scripting.

Adding a global variable so we can set up a ‘Flip Attack’

Let’s break down what was added to this script. I am using the B Button as the attack button in this [Attach Script to Button] event. If you are not, change yours accordingly. Next I added a [Variable Set To ‘True’] event at the top of the script. I picked a Global Variable, and called it ‘Attack’ – or whatever you prefer. Next, change the player’s animation state to an attack state, if you don’t use a custom one to show that your character is attacking, then skip this step. Beyond that, you’ll see the same Launch Projectile event that was added above.

The [Wait] event is set to the same amount of the Life Time in the Launch Projectile event. This way, it changes the animation state back to Default at the same time. Finally, it is finished off with a [Variable Set To ‘False’] event, to reset the attack variable that was set at the beginning of the script. This basically gives the game a window of time that the attack takes place, so whenever it’s finished it will turn off and no longer trigger a flip attack unexpectedly.

Add the launch projectile code to the horizontal flip to allow for a melee attack in the new direction.

Finally, you’ll need to add or copy the Launch Projectile event that was already made inside of an [If Variable Is ‘True’] event after the Set Actor Directions script in the script that was made earlier (both directions, this image only shows for Left). This sends out another attack when the direction is changed. Feel free to edit the Life Time — half is probably good — to reduce the attack timing. Otherwise it might be something players can exploit.

Let’s look at the difference. Here it is without the additional attack:

Nemo jumps and tries to flip the attack, but it doesn’t work.

And here’s with the additional attack there. Much better!

Nemo jumps and flips after attacking, now it hits the enemy!

Wrapping Up

Thanks to these simple fixes, you will gain additional control that you otherwise might not have even realized was missing. I guarantee it will make a tremendous amount of difference when playing, as nearly all platformers allow mid-air directional changes, and ultimately it feels better. Along with the extra attack on the horizontal flip, you’ll have a really tight system that allows for even more control over how you interact with your platformer, and certainly, your players will thank you for it!

I look forward to seeing what kind of great platforming titles you are able to create with these new tips. If you haven’t yet, join the official GB Studio Discord and share what you’ve done with our community! You can also play the demo for my game, Little Nemo: The Slumberland Hero, on my itch page.

Liked it? Take a second to support GB Studio Central on Patreon!
Become a patron at Patreon!