@ChevyRay @MattThorson @legobutts @apsalar i hope to god my brain doesn't decide to use this image to generate my dreams tonight or do i (Today)

@MattThorson so I talked to them about that and they say that they have it in there? but yeah if it's there definitely not long enough (Today)

@MattThorson YES!!1 (Today)

@MOOMANiBE thoughts and prayers (Today)

@MOOMANiBE mine was holding up a cintiq which is heavier than a regular monitor I guess but the reviews said it would be fiiine (Today)

@MOOMANiBE yeah I guess this ikea desk cant hold the weight but the arm also wasn't really doing a great job either -_- (Today)

my ergotron monitor arm just broke a huge chunk off of my desk when I tried to move my tablet so hows your day going (Today)

@floatvoid reboot is so heart breaking. it is forever cursed by misguided attempts to revive it in the most bizarre ways. rip tony jay ;_; (Today)

@The_BenMears yeah I'm subtweeting (Today)

@konjak hahahahah good lord man too soon (Today)

@konjak If Doug Funny says it's okay then it's fine by me t.co/aB7M7isnjT (Today)

I'm reminded of this tweet almost every day #pineapplelife t.co/mRNlM1CBI0 (Today)

@ag_radley that feel when you go to breakfast with people at like 9am and someone orders a coke (Yesterday)

@MattThorson is it the part where the world opens up and you can steal cars and helicopters and rob banks tbh that felt kinda off to me (Yesterday)

RT @mwegner: Had a lot of questions about network-wide VPN setup. Here's a quick video showing my setup: t.co/ytdbmnwdcU (Yesterday)

@mwegner @RAGEBARRAGE I use them for my devices but gonna probably throw it on the router now -_- (Yesterday)

@mwegner Is this through PIA? (Yesterday)

had a weird dream that @dannyBstyle went up an escalator the wrong way into a giant glass boat and said "I'm a 90s kid, this is what I do" (2 days ago)

@ChevyRay I think you're really dang good at it to achieve that pace. It takes me like forever and a million years for editor features ;_; (2 days ago)

@infinite_ammo cancel all my meetings that i didn't have. looks like i have other plans for today. (2 days ago)

follow
search

2013 - 4 - 4 / 1:04 pm / general

Jump Input Buffering

Jump Input Buffering

Yesterday I updated Super Ninja Slash with a few tweaks, including the addition of jump input buffering. I talked about this a little bit on Twitter, but due to the 140 character limit I think I might've caused some confusion as to what I meant by jump input buffering.

First what I mean by input buffering is allowing the player (or any source of input) to input commands into the game and allow those commands to be effective for a short window of time after they are inputted. In the case of jump input buffering, the goal is to allow the player to input the jump button and still have a successful jump even if they mistimed their input by a tiny amount.

I made some doodles to try and illustrate what exactly is going on. Imagine that this is some typical platforming game.

Image

That pink box is the player descending from a jump that happened a little while ago. Imagine that in this scenario the player wants to immediately jump again after they touch the ground, so they try to push jump as soon as they touch the ground...

Image

They push the jump button here! Oh no, they actually pushed the jump button right before they touched the ground. This is a problem because in this example, my platformer jumping code is basically just "if player is on ground, and player pushes jump, then jump!" Since they are not on the ground, that code won't fire. Instead of jumping, they land on the ground like so.

Image

This sucks! As far as the player can tell, they pushed jump at the right time. With the game running at 60fps, they would have to hit a frame perfect timing of 1/60th of a second to actually jump on the very first available jump frame. If this were a game that had a big speed running element, then this would be pretty tough to consistently pull off, and I don't want the player to have to grab a frame perfect input just to jump as soon as they can.

To fix this I can buffer the jump input. This is just fancy speak for having a short timer variable that acts as the jump input instead of a boolean. When the jump input is pressed, set a timer to an amount of your choice. In the case of Super Ninja Slash, it's 6 frames of buffer time. When that timer is greater than 0, count it back down to 0. Now instead of checking to see if the player has pressed jump, I check to see if that timer is above 0. I also set the timer back to 0 if the player is not holding down the jump button at any time. If the player successfully jumps, I set the timer to 0 as well.

With this new system, the example now looks like this.

Image

Image

Awesome! The player now jumps again as they would expect in their brain. The key of making this work well is to choose a timing window small enough that the player does not really notice the helping hand that the game is giving them.

I make use of this technique in Offspring Fling to help make speed running levels a little bit easier. When playing Offspring Fling I found that the best runs of levels were when the player could jump on the very first available frame of a legal jump, however the timing of hitting that frame perfect was way too tough to get consistently. The jump input buffering helped a lot and in my opinion made speed running levels a lot more fun and consistent.

Jump input buffering is NOT when you jump again simply because the player is holding jump. You definitely want to have a small timing window for this, and only jump again if the player has PRESSED jump again. If you simply jump again while the player is holding the jump button, it can feel pretty goofy mostly because the jump action is now disconnected from the input. You want to avoid feeling that disconnect when adjusting your timing window for the buffering.

I hope this clarifies my tweet a little bit!

13 Comments
Avatar

2013 - 4 - 4 2:15 PM

Matt Thorson

There's also a complimentary technique: letting the player jump a few frames after running off a ledge (even though they're technically no longer standing on solid ground). Sorry if I just spoiled the next blog post!

Avatar

2013 - 4 - 4 2:26 PM

Greg Lobanov

I..... never actually thought to do this before, despite having made a bunch of platformers. Good technique!

Avatar

2013 - 4 - 4 2:48 PM

Kyle

MATT!! Actually I was going to mention that, but decided not to in this blog post since I didn't want to distract from the topic at hand. I'll cover the ledge jumping in another post :)

Avatar

2013 - 4 - 5 12:20 AM

Federico Fasce

Totally awesome.
Just a question: you said that you set the timer at 6 frames time.
Wouldn't it be better to set it in a time-dependent/frame-independent fashion?
So, no matter the speed of the computer you only have that "grace time" to jump.

Avatar

2013 - 4 - 5 1:07 AM

uffle

Frederico in my experience console-style action games tend to live and die by the frame counter. If you're not reliably drawing to speed there are going to be a whole lot of problems with responsiveness, and mixing frame-dependent calculations with delta-time stuff is likely to cause more issues than it might theoretically solve. Not really worth it, in my opinion.

Avatar

2013 - 4 - 5 2:46 AM

Fedyfausto

i've send you an email with my project :D

Avatar

2013 - 4 - 5 3:57 AM

Miguel Gonzalez

Awesome article! I never had that kind of problem but I'm gonna use this technology in my next game.

Avatar

2013 - 4 - 5 11:10 AM

Kyle

@Federico Fasce: That would apply if I was using a dynamic framerate, but for all of my games I use a fixed framerate of 60fps, so that I can do math with frames. It's just my personal preference to use a fixed frame rate, but if you were using delta time you'd probably want to use milliseconds instead of frames to determine your window.

Avatar

2013 - 4 - 20 8:51 PM

Will McCullough

I found this article to be really great. The implementation is dead simple and it works excellently (I couldn't help but test this out for fun!).

Avatar

2013 - 5 - 6 6:08 PM

James Liljenquist

Now you're jumping with Pulver. Kyle Pulver.

Thanks for this. Blew my mind!

Avatar

2014 - 3 - 18 10:15 PM

MFcoffee

Not really crazy about making platform games, but I had to admit this article made a great point and suggestion, definitely a good read regardless.

Avatar

2016 - 3 - 18 2:06 AM

Nick Yonge

This info still remains super rad and handy! Just came across this and used the same method for a tile-based action game. It takes about 0.5s to move from one tile to another, and if the player tries to move during that time the move gets queued for when they're finished moving on the one tile.

So good :D

Avatar

2016 - 3 - 23 9:49 AM

Kyle

Yay awesome!! :D

Avatar

Post your comment!

POST COMMENT

about

About

Hi! My name's Kyle, and I make video games most of the time in Denver, Colorado. Here you will find my thoughts, games, websites, doodles, and other stuff like that. I worked on Snapshot, Offspring Fling, and a whole bunch of other games. I also created and maintain Otter, a 2d game making framework. If you want to get a hold of me use the form on the bottom of the page, leave a comment, or just tweet at me. I try to post three times a week. Thanks for stoppin' by! You're the coolest.

blog stuff

categories

tags

archives

facebook

videos

Do you want to make a Let's Play of one of my games, or a just a video featuring footage of my games? You have my full permission to do so! Even if you are monetizing your videos, you still have my full permission to use any footage from any of my games. Go for it!

contact

Your message has been sent! Thanks :)
SEND MESSAGE