How do I create a variable player 'dash' on double key press

Get help using Construct 2

Post » Wed May 21, 2014 8:24 pm

As the title says, I'm trying to implement a dash which a player can perform by double pressing the left or right directional keys. I also need the dash to move the player at a set speed and distance which can be cancelled when the directional key is released.

I.E. Double tap and hold to dash without a fall speed for the determined distance/time. Release at anytime to cancel the dash.

I'm brand spanking new to Construct 2 so please feel free to give any examples which may help me along. I've stumbled through some rough renditions of the dash, but they've so far all been on single key press and at a fixed distance, which aren't really what I'm looking for. I'm not certain how to implement an action on double key-press, or a variable dash distance based on duration of the dash-key held.

Thanks in advance for any help!
Posts: 4
Reputation: 555

Post » Wed May 21, 2014 9:47 pm

First you need to solve the issue with the doube tap. This generally is done by using a global variable, ex: tapped set to 1 when the key is pressed, and it is set back to 0 in, say, 2 seconds. If you press the same key again when the tapped variable is 1, then you achieve a double tap. You should probably tie the "double tap timer" variable to a global variable as well, so that you can fine tune it.

İf you wish to keep dashing as long as the key is pressed, this means dash is like a state, you will probably want to make another variable like IsDashing, and set it to 1 when the double tap is complete, set it back to 0 at each key release. (You must store the dash-starting key in another variable as well, because maybe the player can dash to right and left, maybe even up and down)

Below subject has some examples to double-touch event, you could improvise them to suit your needs I think. It would also be a good exercise:

Welcome to C2 and hope you find it to your liking.
Posts: 332
Reputation: 3,149

Return to How do I....?

Who is online

Users browsing this forum: mistia, TGSBRD and 4 guests