x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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.

alt text

Product Version: UE 4.20
Tags:
jumptest.png (261.0 kB)
more ▼

asked Nov 14 '18 at 10:14 AM in Blueprint Scripting

avatar image

TNinja 0
7 1 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

more ▼

answered Nov 14 '18 at 02:33 PM

avatar image

ThompsonN13
10.1k 33 10 23

avatar image TNinja 0 Nov 14 '18 at 10:16 PM

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.

alt text

jumpdone.png (173.3 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I don't know if this is a the right solution but this is diffrent perspective :P

alt text

mariostyle.png (142.0 kB)
more ▼

answered Nov 14 '18 at 10:37 AM

avatar image

Sertac Ogan
1.5k 30 10 46

avatar image TNinja 0 Nov 14 '18 at 11:17 AM

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?

avatar image Sertac Ogan Nov 14 '18 at 12:20 PM

Okay then, another different solution below (: alt text alt text

jump.png (108.9 kB)
timeline.png (16.7 kB)
avatar image TNinja 0 Nov 14 '18 at 03:00 PM

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

alt text

errorjump.png (111.7 kB)
avatar image Sertac Ogan Nov 14 '18 at 05:02 PM

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

avatar image TNinja 0 Nov 14 '18 at 05:23 PM

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.

avatar image TNinja 0 Nov 14 '18 at 10:18 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question