Building a Celeste-style platformer jump

GameCeleste
Built withUnity 6 (6000.4.3f1)

What I’m looking at

Celeste, a hard platformer, is full of hidden mechanics: coyote time, jump buffering, tuned gravity and more. The sprite’s proportions also change on takeoff and landing.

That level of polish in the controls is a big part of why so many people love the game, me included. I got curious how you’d build a jump that tight and that good to control. You can’t think of a jump as something that simply goes up and comes back down. The actual speed along the arc, the input windows and the visual feedback all have to be designed.

Just Rigidbody2D.AddForce?

This approach just gives an upward impulse. The character rises, and gravity brings it back down. Gravity is left to the Rigidbody2D’s gravity scale.

// CelestePlayer.cs, ProcessOldJump()
var buffered = now - lastPress <= 0.1f; // input buffer
if (buffered && grounded) // pressed, and a jump is allowed
{
    rb.AddForceY(jumpSpeed);
    lastPress = float.NegativeInfinity;
    grounded = false;
}
AddForce jump

(This is how I did the jump in SQUARE::ERAUQS a while back..)

As you can see, the jump feels far too floaty. Also, if you only add an impulse, the jump comes out different when standing still and when falling, so a consistent jump needs a set starting velocity as well.

But fixing the starting velocity can also overwrite external forces you need.

Tuning gravity

In Celeste, when the absolute vertical speed is below a certain threshold, gravity is applied at half strength. In other words, the character slows down near the apex. Normal falling also has a max speed. Developer’s write-up · NormalUpdate code

Lowering the acceleration at the apex gives you time in the air to adjust where you land. That’s why it suits a hard platformer that needs precise control.

When falling, it goes the other way: turning gravity up a lot means you drop fast and land with a snap instead of floating around.

Easing the apex and strengthening the fall are separate choices, and there’s no need to push both hard at once. I put both in because I was curious.

// CelestePlayer.cs, ProcessJump()
if (!grounded)
{
    float mult = 1f;
    if (jumpHeld && Mathf.Abs(v.y) < 2f)
        mult = 0.6f; // softer gravity
    else if (v.y < 0f)
        mult = 1.5f; // stronger fall

    v.y = Mathf.Max(v.y - gravity * mult * Time.fixedDeltaTime, maxFallSpeed);
}
rb.linearVelocity = v;
The two jumps side by side

Tap for a short jump

Next, I wanted a short press to jump low and a long press to jump high.

In Celeste’s public code, holding the button for a limited time keeps correcting the upward speed, and releasing it ends that correction. Variable Jumping code

I went simpler: when the button is released while rising, the upward speed is cut once. For example, releasing the button mid-jump multiplies the current upward speed by 0.5.

// CelestePlayer.cs, ProcessJump()
if (!jumpHeld && !cutApplied && v.y > 0f) // released while rising
{
    v.y *= 0.5f; // short jump: cut the upward speed
    cutApplied = true;
}

The cut happens only once per jump (cutApplied).

A held jump and a tapped jump.

Coyote time

From what I found, the name comes from the Coyote in Looney Tunes. It’s a classic game technique that still allows a jump for a short moment after leaving a ledge.

The player sees the edge of a platform and presses jump, but as far as the physics is concerned they may already be in the air. Strictly, the jump should fail, but sometimes that just feels annoying. So you give a little grace time.

Coyote time in Celeste’s public code is JumpGraceTime = 0.1f, so 0.1 seconds. Public code

While grounded, coyote time is refreshed, and once you leave the platform it runs down. A successful jump has to use up both the grace time and the input. I record the last grounded time (lastGroundedTime) and decide from the difference between that and now. Jumping resets that time to -∞.

// CelestePlayer.cs, ProcessJump()
if (grounded)
    lastGroundedTime = now;
// ...
var buffered = now - lastPress <= 0.1f; // input buffer
var canJump = grounded || now - lastGroundedTime <= 0.2f; // coyote jump
if (buffered && canJump) // pressed, and a jump is allowed
{
    v.y = jumpSpeed;
    lastPress = lastGroundedTime = float.NegativeInfinity;
    cutApplied = false;
    grounded = false;
    stretch = jumpStretch;
}
coyote time

Jump buffering

If coyote time forgives an input that’s a little late, the jump buffer handles the opposite: an input a little before landing. Press and hold jump just before you land, and the jump goes off the moment you touch down.

Make it too long and an input from way back causes a jump you didn’t mean. The buffered input also has to be used up by the movement code. On restart or death, old input is cleared.

Update only records when the button was pressed, and the jump check in FixedUpdate treats it as a buffered input if it was within 0.1 seconds (buffered in the code above).

// CelestePlayer.cs
void ProcessJumpInput()
{
    if (Input.GetKeyDown(KeyCode.Space))
        lastPress = Time.time;
    jumpHeld = Input.GetKey(KeyCode.Space);
}
// CelestePlayer.cs, ProcessJump()
if (grounded)
    lastGroundedTime = now;
// ...
var buffered = now - lastPress <= 0.1f; // input buffer
var canJump = grounded || now - lastGroundedTime <= 0.2f; // coyote jump
if (buffered && canJump) // pressed, and a jump is allowed
{
    //...
}
With the jump buffer, pressing a little early still jumps.

You can keep the buffer even after the button has been released. If you do, and jump height depends on how long the button is held, you have to decide which jump comes out next.

If just holding the button refills the buffer every time, you get automatic repeated jumps, so a new press has to be told apart from a held button. That’s why the code above reads GetKeyDown (new press) and GetKey (held) separately.

A bouncy sprite, too

For a punchier feel, I also change the sprite’s scale. Stretching it tall when the jump starts plays up the upward push, and stretching it wide on landing shows the impact. It’s a kind of visual feedback.

Celeste’s public code sets Sprite.Scale to (0.6, 1.4) on a jump. On landing it changes the width and height ratio based on fall speed, then brings it back to normal size. Jump / OnCollideV / UpdateSprite code

One thing to watch: stretching the collider too can change the hitbox, so always keep the sprite separate from the collider. I put the sprite on a rendering child (visual) and only change its scale, so the collider on the root stays the same size.

stretch is set to jumpStretch the moment the jump goes off (the last line of the coyote time code above) and to groundedStretch on the first grounded frame, and LateUpdate eases it back to normal proportions.

// CelestePlayer.cs
// ProcessJump(): first grounded frame
if (grounded)
{
    lastGroundedTime = now;
    if (!lastGrounded)
    {
        stretch = groundedStretch;
    }
}

// LateUpdate()
visual.localScale = Vector3.Scale(Vector3.one, new Vector3(stretch.x, stretch.y, 1f));
stretch = Vector2.MoveTowards(stretch, Vector2.one, stretchAccel * Time.deltaTime);

I used one fixed value, but like the original you could scale the landing squash with fall speed.

The two jumps side by side

Last thoughts

Making one jump took more thought than I expected. Of course, how it’s done varies a lot from game to game, and there’s no one right answer. Still, I think building each of these small-looking details with care is the first step toward making a masterpiece. That’s also why I picked this as my first topic.

Beyond jumping, Celeste has wall climbing, dashing, momentum storage and plenty of other well-made mechanics. If I get the chance, I’d like to cover those too.

References

Asset credits

  • Luneblade — Art by Jesshiyoo

About

Seongwon Choi 최성원

Game Programmer

qwik0102@gmail.com