Hey all,
I am building a 2D game and I have a double jump function. Everything works fine, except when I play on mobile, the jump button (I put a new virtual button so I can do simultaneous controls) and hold the button, my character shoots straight up. This doesn’t happen on PC, and I have already tried changing jump max hold time to various values and all this does is stop me double jumping at all on mobile. Can anyone help please? Thank you
Hey there @Dark_Sayajin! Much of the time this stems from the UI input binding not really following the same input binding settings as the input it’s emulating. May we see the blueprints and the input settings? Might be able to figure it out from that alone.
Hey,
The input for jumping is the space bar. I set the same for the button, as shown below (it’s the second one), however I am guessing because it isn’t the same as the PC input that’s why you can hold it and fly? Here’s characters BP:
The character can jump from walls, but yeah apart from that that should be everything. Thank you!
Oh yeah there we go. So your button doesn’t seem to call stop jumping, this is there to stop the player’s jump before it reaches max height, but also for the double jumping system you need to call stop jumping before it counts the other jumps, which is making you fly. So make sure your character has 2 jumps listed in it’s settings first, and then you need to be able to get the input up from the mobile events and pass that to stop jumping.

Your widget for the button has 2 functions for this already, On Pressed and On Released. Use that to call two different events on your player controller.

Hope this helps!
Thank you! I did this:

And it seems to fix it. Thanks again!
Awesome! That’s another way to do it for sure! I tend to consolidate all of my inputs that can be so that all cross-platform stuff can be done pretty quickly. There’s always a million ways to civilization and as long as it gets the job done and doesn’t cause too much tech debt I approve!
Hey, it actually doesn’t work! I don’t know how to untag as solution… I didn’t really understand what you meant because the jump button isn’t a widget as it wouldn’t let me use it whilst say running, so I made it as an actual seperate mobile button if that makes sense?
I got it for you no worries. Now the issue we have is a common one. The baseline mobile controls system isn’t really made for buttons, it’s made for axes. This means there is no pressed/released coming from that, just constantly passing in a number and anything over .01 will fire the event. So what’s happening is your keyboard controls for it are being called every single frame but with no stop jump. So we have a couple of options here. Well a bunch of them really but some are hackier than others.
1: So for standard buttons in mobile controls I use UMG for buttons functionality and turn off focusable so it can’t steal focus from the joystick and disable your movement. I generally use this method in most games.
2: (a little hacky) You can set it to an axis style of input like one of the gamepad axes and whenever it’s really close to 0 you can call the release button.
3: (Still hacky) You could make a totally separate input and have a Do once that resets after a delay that calls stop jumping,and will accept another jump if you have the count, then if after the delay there are no more jumps it calls stop jumping and lets you fall.
1 Like
Right I understand now, so do you mean untick this for the buttons and it’ll work fine?
As in I untick that for all the buttons on the right, delete the additional mobile control I put in and just keep the one joystick and it should work?
So I just unticked focus, and it works perfect. This was the only part I was stuck on, thanks so much for your help!
Sorry about the late answer, I went to bed for the night haha. I’m glad it worked out for you! Most mobile games buttons use it that way, I do wish we could get an expanded mobile controls system for buttons so it was the standard hud, but in the meantime this is the standard. Important side note: Avoid setting any buttons that gamepads may need to focus as un-focusable as it will cause some issues. Since your project’s primarily mobile I don’t see it being a major issue, but just letting you know now!