How to I make my 2d platformer so when I hold A, the player jumps higher, but a short tap makes the player jump lower?
If you know the game Celeste, or Hollow Knight, this is a feature, and i want to add it to my game, its a usefull mechanic for platformers
You could make it so that each second that the A button is pressed, the characters y-velocity decreases. This means short presses result in less upward speed, but long ones result in more. You would also want to add that on the A button being released, velocity should return to normal!
the microsoft/arcade-platformer extension has this functionality built in!
also has a lot of other niceties like ācoyote timeā and a grace period for jump button presses
can you show me how to do this?
If you send the code yeah, did you mean my or richardās solution?
richards sorry.
i got the arcade-platformer extensions loaded but its really confusing to use.
I also am looking for a solution to this. I have been trying to get the extension to work also. When I load it it comes with a bunch of errors in the physics.ts and doesnāt load any blocks. Iāve tried loading the demo but there is no code inside and nothing runs.
I tried doing this in my own game, and it worked perfectly! However, the sudden āstopā of the y velocity is quite annoying, to say the least. Is there any way I could smoothen out the velocity when stopping the jump? Also sorry for reviving this old topic
Sorry for late reply - Yeah! You could add that instead of immediately returning the y-velocity to normal, you could slowly turn it to normal over a period of maybe half a second. Something like a repeating block that continually averages the old y-velocity and the normal one would create a nice curve!
Could you show me an image on how to make that? Iām kinda confusedā¦
Sure!
Press B to activate the new kind of jumping I mentioned.
It averages the y-velocity and the desired y-velocity (16 in this case) 5 times to make a gradual change, then sets it back to 16. You can play around with the values to get a better effect as well.
Uh, this is great and all, but two things. One, pressing B does nothing, I think you meant press A. And two, I meant a smooth change in y velocity like the robot gamemode from Geometry Dash. Thanks for helping anyways!
Oh yeah! I looked it up, I think this is what you mean:
A to jump again- in an actual game, you might want to put a limit on the āpressā variable to avoid huge jumps, and obviously not let them jump mid-air!
Thanks! This was exactly what I wanted!
How to do this though?
Maybe only let the āpressā variable increase when it is less than a certain number?
platformer⦠extension? so, i didnāt have to code that myself?
am i an idiot?
oh god, i think im an idiotā¦
No you fine
If you want custom dashes and stuff you need your own
Knowledge! Learning! the memory of this fun discussion!