How do I make a character capable of jumping + flying with the same button?

So I’m making a third-person game, and I want my character to be able to walk, jump, crouch, the works. However, I also want the character to fly after holding down the jump button for a few seconds, entering a state where gravity doesn’t have an effect until they use the crouch button to descend and touch the ground again, putting them back into walk-mode. (I hope the description doesn’t sound too confusing!)

Is there a way to do this with blueprints? Well, I know there’s likely a way, but I’m really new to blueprints and coding in general, so a guide or some steps to follow would be really helpful!

I was initially just going to make fly up/down on a new axis and control it with separate movement keys (like Q and E), but my boyfriend insisted I try to find a way to make it work with holding down jump and crouch, for a simplified control scheme.

Thanks for reading!

Hrm, this isnt the the optimal way to do this, but if youre just making a game for fun itll suffice. You can have the jump button activate and deactivate a boolean based on whether it is held down or not (true if its down, false if it isnt down). On activation of the boolean delay for however long you want them to hold it down and then check if its still held down at that point.

Just do event tick → branch is jump held down —> delay however long you want them to hold it down for → branch is jump held down → trigger flying state

Hope this helps, there is definitely a better way to do this as this method causes a few problems, but hopefully it’s good enough, or it inspires you to think of a better way lol
Good Luck!

EDIT:
Using my method combined with what the guy below me said is optimal, just mash our responses together and it’ll be great!

You can use “Get Input Key Time Down” which is from the Player Controller (have to get player controller if using outside of player controller.) This returns a float value that you can use with say a branch to see if the return value is greater than 3 (for 3 seconds) and if so it will return true and execute your logic. Obviously you would need to put this in a tick or an Input Action (which is similar to a tick) for it to continue counting up while pressed.

To return to walk state just add a collision check that if the pawn hits the landscape it returns to walk mode.

Hope this helps! If it does, please accept the answer by clicking the check mark located under the arrows next to the answer! Take care

I’m pretty sure there’s event that happens at the peak of the jump, you could use that to see if the key has been “released”, and if not, disable gravity and fly.

You wouldn’t want to disable gravity though as everything in the level will also lose gravity. You simply need to manipulate the characters Z location for height (I believe there is also a “fly” command since you can manipulate those values in the character movement, like you do walk and swim speed.) Plus no gravity will give your character the physics of being in space. Unless that’s the location of the game then it will produce undesirable effects

Sorry, let me rephrase: Change the Gravity Scale for the Character Movement. Works perfectly fine for my character I want to “FLY”.

Not entirely sure how to use Apex, (Character or Controller), I haven’t used it.

52552-set+gravity+scale.png

Ahh yes gotcha. BTW Apex is for simulated clothing. It’s a program from Nvidia you can use with your 3D modeling software to create realistic movement with cloth.

Apex is just the name for their system. It actually refers to the tip of a jump:

https://docs.unrealengine.com/latest/INT/BlueprintAPI/EventDispatchers/OnReachedJumpApex/index.html

and

Hope this helps! :slight_smile:

Awesome… I didn’t really look at the nodes and see “OnReachedJumpApex” because I was on my phone. Just assumed it was for Apex cloth simulation. Thx

Alright, so I feel kinda silly because I partially understand most of what you’re saying, but I’m terrible when it comes to putting it into practice. This is what I have, and I think I have the right idea? But I hadn’t set up a Player Controller or anything beforehand, and my character isn’t doing anything when I hold down the jump button, so I know I’m definitely missing something or setting things up incorrectly. Any chance I could get some more help figuring out what I’m doing wrong? Thanks!