Control Jump Height Midair

Hey, I’m fairly new to this.

I’m dealing with a 2D side-scroller, and I’d like to control a character’s jump height by simply holding the button, and releasing it to get a lower height.

So far I’ve tried, the character either abruptly falls, making a sharp jump to fall, or the character makes a small midair jump.
I’d like it to go smooth.
In easy words. I’d like it to work like Super Mario Bros.

Here’s what I’ve tried so far.
I used enumerator to assign different jump states to create conditions, and changed velocities accordingly. Or so I’d like to think.

I don’t know if this is a the right solution but this is diffrent perspective :stuck_out_tongue:

1 Like

Hm. This seems to be much smoother than what I’ve been trying. Though, I can’t figure out why it works. I didn’t tell the floats to directly interact with the engine’s gravity, or press timer. Unless the engine checks for just the names and then starts connecting the interactions?

Regardless. About this solution.
There’s a problem here. It seems the gravity becomes much heavier if you do short hops, making you fall pretty quickly. It’s noticable on ground level, but if you compare the falling speed from walking off a platform, to shorthopping froma platform, the falling speed would be noticable.

It seems this is what happens if you use gravity to adjust jumping height. Would there be a workaround for this?

Okay then, another different solution below (:

259354-timeline.png

not sure with 2d but i know with the third person character you can use the jump max hold time which limits how long the character can keep jumping. basically allowing the character to keep going up as long as jump is held, the option itself is what places a limit on how long the jump can last. in your particular case you could set it to about 1 second, then is the player holds jump for 1 second they will go to the height accordingly, but if they release before 1 second it will stop the jump when they release. guess a bit hard to explain but check it out. in the third person character if you click the class defaults near the top, then look in the details panel for the character section, in the character section you will find the jump max hold time option as well as the max jump count option.

Looks like that froze the test.
Odd. I don’t think I missed anything.

What does it mean froze the test? Did you remove breakpoint with F9 key?

Ah it now works. Though, the jump height is very inconsistent for some reason. I’m holding the button at full duration, but it seems to not really jump either too short, or too far. Quite puzzling,as the value should have been counting up to 100 within a second.

Ah, this worked wonderfully. I do thank you.

So what is done is I noded from Construction Script to JumpMaxHoldTime, and noded the values from a custom variable I called MaxJumpHoldTime (For my own convenience). All so I could see and tweak the numbers if I needed.

Then went to the character and just basically add a Jump and Stop Jumping as one would.

Finally, tweaking Gravity and JumpZVelocity.

Personally went for
MaxJumpHoldTime: 0.5
JumpZVelocity: 650
GravityScale:2
MaxAccelerator: 4000

Ridiculously simple solution, that I overcomplicated. What a fun experience.

1 Like

I have now gotten this to work. Quite simple, really.

But I do thank you for your time. These solutions gave way for some new movement mechanics I could try out.

It would be great to finish this thread with how exactly did you get it to work so others can do it TNinja…

Thank you for this!