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

0 favourites
  • 5 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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!

  • 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.

  • This was awesome! Thank you OP for asking this and thank you Windwalker for that awesome response! I'm new and I understood that completely! And also i'm 4 years late

  • ....

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This was awesome! Thank you OP for asking this and thank you Windwalker for that awesome response! I'm new and I understood that completely! And also i'm 4 years late

    so you can like show an example of the sheet?.. i have the same question and I didn't understood absolutely anything of the answer. it doesn't say if the variable should be boolean or text... and how to call it and from where?... jeje I know nothing about programming in case it doesn't show already.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)