# Variable Jump Height? Longer key presses yield a higher jump?

**URL:** <https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [March 6, 2015, 5:44am UTC](https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041 "2015-03-06T05:44:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_03a374781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_03a374781](https://forums.unrealengine.com/u/anonymous_user_03a374781)\
**Post date:** [March 6, 2015, 5:44am UTC](https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041/1 "2015-03-06T05:44:14Z")

</div>

Hey, guys! I’d like to edit the jump mechanics in the Third Person Template such that, when the player holds the jump button down, the character will jump higher. In contrast, I’d like a quick button press to result in a short hop. This would give the player much more control over the character’s jumping, making platforming feel more natural.

Where might I get started with such an endeavor? Since I’m sure there are many other platformer enthusiasts about, I’d be sure to share my method, should I get this working, but I’m unsure of where to get started. Any ideas?

---

<div class="post-metadata">

**Author:** ![kenmorechalfant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kenmorechalfant](https://forums.unrealengine.com/u/kenmorechalfant)\
**Post date:** [March 6, 2015, 5:52am UTC](https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041/2 "2015-03-06T05:52:47Z")

</div>

Jump on key release, jump velocity based on how long the jump key was held down?

Basically, here’s what I’m going for:

When the player holds down the jump key, the jump will sort of “charge up” from a minimum jump velocity to a maximum jump velocity. The player will jump when the jump key is released or the maximum jump velocity is reached.  
For my purposes, it will probably be a small amount like 0.0 to 1.0 seconds.

Where I’m stuck is: I need to figure out how to start counting how much time has passed once I hold down the key; and how to get the elapsed time on key release.

---

<div class="post-metadata">

**Author:** ![Uniname77](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Uniname77](https://forums.unrealengine.com/u/Uniname77)\
**Post date:** [March 6, 2015, 7:29am UTC](https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041/4 "2015-03-06T07:29:02Z")

</div>

You can check out jumping mechanics here [https://answers.unrealengine.com/questions/26162/charging-a-jump.html](https://answers.unrealengine.com/questions/26162/charging-a-jump.html)

Timers would help with your count issue [https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseTimers/Blueprints/index.html](https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseTimers/Blueprints/index.html)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_03a374781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_03a374781](https://forums.unrealengine.com/u/anonymous_user_03a374781)\
**Post date:** [March 6, 2015, 8:03am UTC](https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041/5 "2015-03-06T08:03:21Z")

</div>

I’m not trying to charge the jump beforehand and have them jump on release. Consider Super Mario Brothers: A quick tap of the jump button will make Mario jump only slightly, but a longer press will have him jump higher until he reaches the maximum. This charging and releasing system isn’t exactly what I was going for, but I suppose it will have to do for now. I’ll see what I can do with it.

In the meanwhile, are there any other methods that someone could suggest?

---

<div class="post-metadata">

**Author:** ![kenmorechalfant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kenmorechalfant](https://forums.unrealengine.com/u/kenmorechalfant)\
**Post date:** [March 6, 2015, 8:44am UTC](https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041/6 "2015-03-06T08:44:09Z")

</div>

I don’t know why my question was merged in with this one. They are not the same at all.

The OP for this thread does not want the jump delayed until the key is released, but rather, the jump should just add more velocity (mid-jump) if the key is held down longer… Which can be accomplished with the CharacterMovement component included in the Character class.

So, to the OP:

In your Character’s Construction Script, drag off a node from the Construction node and type “jump hold”, under Character, look for “Set Jump Max Hold Time”. Then, I would make an editable variable so you can more easily edit this on your Character later.

 ![WAYeonc.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/1/c/1cc7117cb4f1ad7ed4adcaac6f2c493208dcfbd0.png)

Now, when you select your Character (top left), you should see your editable variable in the Details panel.

 ![PUNXpIa.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/f/f/ff643ea6dc0b7be54ba912f6e793d0526187705c.png)

Over in your PlayerController, you also want to make sure that your only actually calling Jump when the player “Can Jump”; and also make sure to call “Stop Jumping” when you release the key.  
Otherwise, you’ll be able to infinitely ‘double-jump’… going higher and higher… Which is probably not good.

 ![pYT0cMP.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/a/c/ac9bfb497da77307c7f70183dc2b73627fe56577.png)

I think that’s all it takes.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_03a374781](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_03a374781](https://forums.unrealengine.com/u/anonymous_user_03a374781)\
**Post date:** [March 6, 2015, 9:36am UTC](https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041/8 "2015-03-06T09:36:13Z")

</div>

This works pretty well! Thanks! It took a little tweaking of the gravity and the jump height to get a nice-feeling difference between the short hop and the longer jump!

---

<div class="post-metadata">

**Author:** ![preadatordetector](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@preadatordetector](https://forums.unrealengine.com/u/preadatordetector)\
**Post date:** [January 30, 2016, 5:04am UTC](https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041/9 "2016-01-30T05:04:10Z")

</div>

I know I’m necroing this thread, but…

I find that with the MaxJumpHoldTime parameter has a problem. When I release the jump, the character’s jump height is a little bit higher than when the jump button is released. Is there a fix to this, because I feel that this kind of takes control away from the player.

My apologies by the way.

---

<div class="post-metadata">

**Author:** ![maggotcakes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@maggotcakes](https://forums.unrealengine.com/u/maggotcakes)\
**Post date:** [August 11, 2017, 5:11pm UTC](https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041/10 "2017-08-11T17:11:09Z")

</div>

I can’t seem to get this to work… How is the jump input supposed to recognize the variable we created? how are those two things linked? I think I’m missing a key point in those instructions… also would it work if I don’t have a player controller but if the input graph is on the player itself?

---

<div class="post-metadata">

**Author:** ![Wahooney](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/wahooney/32/465596_2.png) [@Wahooney](https://forums.unrealengine.com/u/Wahooney)\
**Post date:** [July 9, 2019, 7:54am UTC](https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041/11 "2019-07-09T07:54:35Z")

</div>

I know I’m a little late to this party, but the way I solved it was to have the character jump with the max velocity when the key is pressed, and when it’s released and we still have positive Z velocity, zero out the Z velocity.

So if we hold the jump button in, we will experience the full arc, but if we stop at any point, the jump stops.

This may not work in all situations, but it worked pretty well for me 😃

---

<div class="post-metadata">

**Author:** ![AlienPixelStudio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlienPixelStudio](https://forums.unrealengine.com/u/AlienPixelStudio)\
**Post date:** [August 26, 2019, 12:35pm UTC](https://forums.unrealengine.com/t/variable-jump-height-longer-key-presses-yield-a-higher-jump/23041/12 "2019-08-26T12:35:25Z")

</div>

On low FPS, Jump Max Hold Time has serious problems. Meaning that the character will always jump more on big FPS
