SOLVED How would I go about implementing a vertical dash button?

GGullz

Member
So right now I'm trying to implement a vertical acceleration button but I'm not exactly sure how I would go about doing so. I've looked up some video/forum guides that would help set up a horizontal dash button but I can't seem to replicate it to work vertically (preferably going down and not up, something like a ground pound but would reset to a max vertical speed where you could dash repeatedly if the button wasn't already pressed).

Could anyone give an example of how this could be done? I've looked into using clamps but I'm genuinely lost on how they would work here with gravity
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Moderator
In my current WIP I have both horizontal and vertical dash and they both work in almost the exact same way. You can see an example here:

The way I did it was to have a "max velocity" value for both the horizontal and vertical speed as well as a "velocity multiplier" variable. So, when no dash key is pressed, the max velocity is set from the normal value of 2 (for example) up to 4, and the velocity multiplier is changed from 1 to 1.75 (or whatever). All speed calculations are multiplied by the velocity multiplier, so the player movement when the dash key is pressed is accelerated, and the top speed is capped by the max velocity value. For the downwards "dash", what I did was that when the dash and down buttons are held together and the max velocity is the normal value, I set the max velocity to double, the multiplier to a higher than 1 value, and then cancel any upwards momentum and add the full maximum velocity to the downwards momentum. You can see in the GIF above that when I do a double jump and suddenly plunge downwards. I was basically cancelling all the current velocity values then setting them to the max.

I hope that's of some help to you, and I'd love to be able to post some code, but I can't easily do that! Basically the movement for my game is about 800 lines of code right now, and it's ALL A BIG MESS of interlinked systems (since I have flying, dashing, swimming, etc... all mixed into the same code). I should really tidy it up and make it better/neater, but it WORKS so I'm rather scared to touch it at this point... 😂
 

GGullz

Member
I hope that's of some help to you, and I'd love to be able to post some code, but I can't easily do that! Basically the movement for my game is about 800 lines of code right now, and it's ALL A BIG MESS of interlinked systems (since I have flying, dashing, swimming, etc... all mixed into the same code). I should really tidy it up and make it better/neater, but it WORKS so I'm rather scared to touch it at this point... 😂
Lol yeah I can see why you’d be afraid to touch it since you’re that deep in. But yes that helped me figure out how I should go about doing mine! Thank you so much!
 
Top