How to enable sprint while holding a button?

Hello everyone. I’m having trouble enabling sprint while holding down buttons. The expected behavior is to have the Player dash when the user holds arrow and Lshift but return to normal speed when Lshift is let go. Currently, the dash works but when I let go of Lshift, the dash speed remains.

Screenshot below, also Player.DashSpeed = 800 and Player.SlideSpeed = 100.

1 Like

Set deceleration to something like 2000

1 Like

Thx for response but that doesn’t seem to work. The dash speed still remains after even after letting go of Lshift but still holding right arrow.

um…do these events need to be nested?

1 Like

Then check don’t you have anywhere events that are overwrithing these ones cause i tested it and your logic works perfectly fine

I know its a little bit different but i testes EXACTLY what you have and it was working just modified it to work with both ways and WASD
And i have absurdly high acceleration and deceleration
And setting CURRENT horizontal speed is not needed
Only maximum horizontal speed is required

@DesmonDev no but cause he is setting current speed
Then without right key pressed
His player will just move on its own

Hello thank you for providing screenshot but even after copying your logic, it still refuses to return to normal speed after letting go of Lshift. Do you think “simulate pressing right” is causing an issue?

I would highly doubt it

Also make new scene and try it there
And we will know if its problem with your events

what is the value of those two variables? also, player is moving is redundant.

Created a new scene and tried it again, still nothing. Even created a new project and the behavior doesn’t change. Perhaps I’m misunderstanding how the platformer object works.

The expected behavior is:
Hold right arrow which is normal speed (works)
While holding right, if I hold Lshift then dash speed (works)
When I let go of LShift (still holding right) then go to normal speed (doesn’t work)

The current behavior:
Hold right arrow which is normal speed
While holding right, if I hold Lshift then dash speed
When I let go of LShift (still holding right), the object is still in dash speed. Only when I press LShift again it returns to normal speed.

I’ve tried a bunch of alterations with this logic with no luck.

Slide speed is 100, dash speed is 800. Deceleration is also set on the platformer character itself to a ridiculous amount.

may i have your project file?

have you disabled default control in platformer behaviour?
it could be a keybinding issue.

Try different key than LShift
For me everything you have should work
And it is working for me with LShift
But that would be my 1st suspect if that won’t help then we gonna make different dash system

Yes I have default controls disabled

I tried with different keys for dash but still nothing lol.

Sure but do you know how I can send it to you? I’m fairly new to GDevelop. If not then I quite literally only have this event logic and objects.


The Player is a platformer object and Platform is Platform object.

Ok 1st we try variable
Make number scene variable and call it Speed
And make two events
Condition
LShift pressed

Action
Change variable Speed set to 100

And 2nd event
Condition
INVERTED LShift pressed

Action
Change variable Speed set to 255

Now put text object into your scene and in events add event WITHOUT any condition with action
Change text of text object set to Speed

And check does pressing/releasing shift changes tex

Looks like the Lshift button on my keyboard is messed up. I tried it using my laptop and it works now. Sorry for wasting yalls time but I very much appreciate the help!

Maybe

https://drakeirving.github.io/MultiKeyDisplay/

https://www.reddit.com/r/pcgaming/comments/5kupov/key_ghosting_why_youre_losing_your_games_many/

And don’t worry if you have issue with key ghosting then i actually learned here more than you did

awesome! thanks for the helpful links.

1 Like