# Variable Jump Height

**URL:** <https://forum.makecode.com/t/variable-jump-height/17628>\
**Category:** Help\
**Created:** [January 27, 2023, 5:08pm UTC](https://forum.makecode.com/t/variable-jump-height/17628 "2023-01-27T17:08:36Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qulbb](https://avatars.discourse-cdn.com/v4/letter/q/e5b9ba/32.png) [@Qulbb](https://forum.makecode.com/u/Qulbb)\
**Post date:** [January 27, 2023, 5:08pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/1 "2023-01-27T17:08:36Z")

</div>

How to I make my 2d platformer so when I hold A, the player jumps higher, but a short tap makes the player jump lower?  
If you know the game Celeste, or Hollow Knight, this is a feature, and i want to add it to my game, its a usefull mechanic for platformers

---

<div class="post-metadata">

**Author:** ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)\
**Post date:** [January 27, 2023, 6:39pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/2 "2023-01-27T18:39:32Z")

</div>

You could make it so that each second that the A button is pressed, the characters y-velocity decreases. This means short presses result in less upward speed, but long ones result in more. You would also want to add that on the A button being released, velocity should return to normal!

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [January 27, 2023, 6:40pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/3 "2023-01-27T18:40:36Z")

</div>

the microsoft/arcade-platformer extension has this functionality built in!

also has a lot of other niceties like “coyote time” and a grace period for jump button presses

---

<div class="post-metadata">

**Author:** ![Qulbb](https://avatars.discourse-cdn.com/v4/letter/q/e5b9ba/32.png) [@Qulbb](https://forum.makecode.com/u/Qulbb)\
**Post date:** [January 29, 2023, 11:56pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/4 "2023-01-29T23:56:31Z")

</div>

can you show me how to do this?

---

<div class="post-metadata">

**Author:** ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)\
**Post date:** [January 30, 2023, 5:22pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/5 "2023-01-30T17:22:19Z")

</div>

If you send the code yeah, did you mean my or richard’s solution?

---

<div class="post-metadata">

**Author:** ![Qulbb](https://avatars.discourse-cdn.com/v4/letter/q/e5b9ba/32.png) [@Qulbb](https://forum.makecode.com/u/Qulbb)\
**Post date:** [January 31, 2023, 1:11am UTC](https://forum.makecode.com/t/variable-jump-height/17628/6 "2023-01-31T01:11:44Z")

</div>

richards sorry.  
i got the arcade-platformer extensions loaded but its really confusing to use.

---

<div class="post-metadata">

**Author:** ![salieri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/salieri/32/7275_2.png) [@salieri](https://forum.makecode.com/u/salieri)\
**Post date:** [March 13, 2024, 6:20pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/7 "2024-03-13T18:20:28Z")

</div>

I also am looking for a solution to this. I have been trying to get the extension to work also. When I load it it comes with a bunch of errors in the physics.ts and doesn’t load any blocks. I’ve tried loading the demo but there is no code inside and nothing runs.

---

<div class="post-metadata">

**Author:** ![AbstractDesigner](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/abstractdesigner/32/22531_2.png) [@AbstractDesigner](https://forum.makecode.com/u/AbstractDesigner)\
**Post date:** [April 7, 2024, 10:58pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/8 "2024-04-07T22:58:16Z")

</div>

I tried doing this in my own game, and it worked perfectly! However, the sudden “stop” of the y velocity is quite annoying, to say the least. Is there any way I could smoothen out the velocity when stopping the jump? Also sorry for reviving this old topic

---

<div class="post-metadata">

**Author:** ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)\
**Post date:** [April 11, 2024, 4:32pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/9 "2024-04-11T16:32:17Z")

</div>

Sorry for late reply - Yeah! You could add that instead of immediately returning the y-velocity to normal, you could slowly turn it to normal over a period of maybe half a second. Something like a repeating block that continually averages the old y-velocity and the normal one would create a nice curve!

---

<div class="post-metadata">

**Author:** ![AbstractDesigner](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/abstractdesigner/32/22531_2.png) [@AbstractDesigner](https://forum.makecode.com/u/AbstractDesigner)\
**Post date:** [April 12, 2024, 3:33pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/10 "2024-04-12T15:33:58Z")

</div>

Could you show me an image on how to make that? I’m kinda confused…

---

<div class="post-metadata">

**Author:** ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)\
**Post date:** [April 12, 2024, 10:57pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/11 "2024-04-12T22:57:52Z")

</div>

> **[Jumping Help](https://arcade.makecode.com/65495-02246-09272-30933)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Sure!  
Press B to activate the new kind of jumping I mentioned.  
It averages the y-velocity and the desired y-velocity (16 in this case) 5 times to make a gradual change, then sets it back to 16. You can play around with the values to get a better effect as well.

---

<div class="post-metadata">

**Author:** ![AbstractDesigner](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/abstractdesigner/32/22531_2.png) [@AbstractDesigner](https://forum.makecode.com/u/AbstractDesigner)\
**Post date:** [April 13, 2024, 1:21am UTC](https://forum.makecode.com/t/variable-jump-height/17628/12 "2024-04-13T01:21:57Z")

</div>

Uh, this is great and all, but two things. One, pressing B does nothing, I think you meant press A. And two, I meant a smooth change in y velocity like the robot gamemode from Geometry Dash. Thanks for helping anyways!

---

<div class="post-metadata">

**Author:** ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)\
**Post date:** [April 13, 2024, 4:43pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/13 "2024-04-13T16:43:29Z")

</div>

Oh yeah! I looked it up, I think this is what you mean:

> **[GD Robot jump help](https://arcade.makecode.com/52869-25112-48633-42566)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

A to jump again- in an actual game, you might want to put a limit on the ‘press’ variable to avoid huge jumps, and obviously not let them jump mid-air!

---

<div class="post-metadata">

**Author:** ![AbstractDesigner](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/abstractdesigner/32/22531_2.png) [@AbstractDesigner](https://forum.makecode.com/u/AbstractDesigner)\
**Post date:** [April 21, 2024, 4:34pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/14 "2024-04-21T16:34:03Z")

</div>

Thanks! This was exactly what I wanted!

> [@randomuser](#):
>
> you might want to put a limit on the ‘press’ variable to avoid huge jumps, and obviously not let them jump mid-air!

How to do this though?

---

<div class="post-metadata">

**Author:** ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)\
**Post date:** [April 22, 2024, 4:54am UTC](https://forum.makecode.com/t/variable-jump-height/17628/15 "2024-04-22T04:54:28Z")

</div>

Maybe only let the ‘press’ variable increase when it is less than a certain number?

---

<div class="post-metadata">

**Author:** ![Brainstorm\_Studios](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brainstorm_studios/32/20476_2.png) [@Brainstorm\_Studios](https://forum.makecode.com/u/Brainstorm_Studios)\
**Post date:** [April 22, 2024, 5:32am UTC](https://forum.makecode.com/t/variable-jump-height/17628/16 "2024-04-22T05:32:46Z")

</div>

platformer… extension? so, i _didn’t_ have to code that myself?

am i an idiot?

_ **oh god, i think im an idiot…** _ ![Screenshot 2024-04-21 173435](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/efc3cdba504f4f9cccfc63cee2dd217cd2aa807d.png)

---

<div class="post-metadata">

**Author:** ![danger\_kitty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/danger_kitty/32/32006_2.png) [@danger\_kitty](https://forum.makecode.com/u/danger_kitty)\
**Post date:** [April 22, 2024, 3:21pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/17 "2024-04-22T15:21:38Z")

</div>

No you fine  
If you want custom dashes and stuff you need your own

---

<div class="post-metadata">

**Author:** ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)\
**Post date:** [April 25, 2024, 4:48pm UTC](https://forum.makecode.com/t/variable-jump-height/17628/18 "2024-04-25T16:48:32Z")

</div>

Knowledge! Learning! ✨ the memory of this fun discussion! ✨
