For the past couple days I’ve been obsessing over how to handle variable jump height in my platformers. I’ve been making platformers for a long time, and I don’t think I’ve been getting it very wrong, but I was never satisfied that it was the best it could be.
Super Meat Boy came out just a few days ago and the running and jumping in it feels great. So what I did is take some video of me jumping in it and measure how Meat Boy moves to see what I could learn. Yeah that was tedious, but I like having the graph. I am such a nerd.
The results were a couple of things that I probably should have already known.
It turns out that the way I’ve been doing it is very close to the way Super Meat Boy does it. Parabolas just feel right (and are physically accurate).
I also added a Meat Boy-style option to that jumping controls tester I made yesterday.
Mike's Blog
Nice.
There was a lengthy thread on TIGS about this years ago – not sure if it’s still going. My approach used to be to modify gravity based on whether the jump button was held down, but now I much prefer the Mario approach of limiting upward speed when the jump button is released (which I discovered in Steve Swink’s book). This feels more immediate than my old approach, but doesn’t have Meat Boy’s invisible-ceiling effect.
I wonder if Team Meat tried both. Did they decide on the invisible ceiling because it gives more intuitive control despite looking a little weird? Perhaps if we’re lucky Tommy will stumble on this post and let us know.
Tommy? You there?
Wow…I was kinda shocked when I came across this. It’s one of the most flattering things I’ve read:)
So here’s what we did:
Gravity is strong in SMB, it is a constant function with a constant rate of acceleration as expected. The Jump upward is a function of velocity, there is no limit to upward speed, it is determined by the weight and upward force of the character. To crest the jump prematurely, I simply turn the upward velocity into 0.0f, and the player just falls. Gravity is strong so they fall quick. The formula is simple and very hacked, the variables we put into the formulas for each character were tons of trial and error until it got feeling just right:)
Tommy
Ah, for various things I’ve done in the past, I’ve done as farbs points out, thinking it was more “physically correct”. And in a certain set of games, it makes sense.
To instantly force the vel.y when releasing is going to give very immediate visual feedback on negative edge button presses, while the “increase gravity but maintain momentum on negative edge” approach, you still get this sense of “vaugeness” to the jump curve. Like “i’m still moving up… did it actually ‘read’ that I released?”.
Realism in game physics is only as useful as far as you can throw it. I think Tommy is right: kinaesthetic perception trumps realism when it comes to designing tight controls.
That was very enlightening.
In the game I’m currently working on (where gravity is possibly stronger than it usually is in platformers), I implemented jump in a jetpacky way: each character is given a jump acceleration and a (very short) time interval, over which the acceleration can be applied to its vel.y, IF the jump button was not released (releasing the button zeroes the jumptime). When the character hits the ground, jumptime is replenished. (While the character is airborne, it’s constantly accelerated downwards by gravity.)
The most prominent downside to this approach is that jump acceleration and gravity need to be tweaked to each other to prevent the jumping character’s take-off having an also jetpacky feel.
The invisible ceiling method definitely looks more immediate and appropriate.
I gotta say I really love this and the Mario graph. I’ve never put too much thought into the mathematics behind the jump aside from just tweaking gravity until it felt right, but when you really analyze it, it makes a huge impact on gameplay and I probably should have taken it more seriously. As you said in the Mario article, there’s no right way to do it, but developers should definitely strive to get the experience that is right for the game. In Mario, the player almost gets a floating on air feeling which compliments the games crazy, block breaking, goomba-bounce comboing style. SMB on the other hand is hard… VERY HARD. So they needed a style that compliments precise movements. I think they accomplished this very well by just zeroing out the y velocity so you got an immediate response. Needless to say, we’ll be putting a lot more thought into our next game!
Chris Enriquez
midnighttangent.com