Making a held button, progress a lerp node.

So I have my jump input and I want to make it so that the longer it’s held down the higher the jump, and then letting go will stop the jump. I have a low and high jump values that I want my jump height to go between, and I have a lerp. Where I’m stuck is a method to set the alpha on the lerp, based on how long I hold the button. How would I go about doing that. Thanks

Hey @IzzyAceDolphin! Welcome to the forums!

Have you thought about using a timeline for this?

Something like so. Sorry for the spaghetti, I just threw this together.


You’ll want to open the timeline and give it a float value to run, then make it as long as you want time-wise. Give it two keys, at 0 value to begin and 1 to end. That’s your lerp alpha. :slight_smile:

@Mind-Brain You code will not actually increase the height during the jump (tested it out). The increase in z jump is already after the jump so it’s not actually doing anything but increasing a value that has already been triggered.

I believe this is the effect what the OP was looking for


The higher the value on the lerp the higher the jump extension. This actually makes the character travel higher during the jump

Normal press = normal jump
Hard press = high jump

I also added that once the character starts falling the offset is no longer added (falls normaly)

1 Like

Hi IzzyAceDolphin,

All you have to do for that behaviour is change “Jump Max Hold Time” to 0.0 - no code needed:

image

1 Like

@3dRaven Awesome! I don’t typically have time to thoroughly test things that seem like they’d work, and I didn’t realize “Jump” locked the Z movement at launch, which stopped my code in it’s tracks! Good looking out, really appreciate it, and I’m sure @IzzyAceDolphin does too!

So it seems like this value changes how long you’re able to hold the button to add additional jump velocity. Is there a setting to change how much extra velocity gets added (without affecting the base jump height). I tried it out and I want the difference between tapping and holding to be bigger, without having to hold the button for longer.