DOUBLE TAP TO DASH

Action style: same key pressed, twice the speed!

  • Avee
  • 05/17/2012 01:16 AM
  • 11961 views
Double tap to dash
For RM2k3 ONLY! (does not work with RM2k)
-----------------------------------

This simple and easy to alter tutorial explains how to code a decent dash system similar to the ones used in several action-oriented games.
You won’t have to waste another key or hold two keys to dash anymore. Only a single arrow key will manage both walking and dashing. Using this system, tapping an arrow key will make the character walk as usual, but tapping it twice within a short time window will make the character dash at double speed.

We are going to code 2 events that change your character’s walking speed depending on how the player presses the arrow keys.

You will need:
-2 Parallel Process events in the Common Events database tab.
-4 Variables entitled “Input Walk”, “Input Dash”, “Memory walk” and “Timer Dash”.
-2 Switches entitled “Timer Dash” and “Dash”
-At the beginning of your game, have the default character movement speed reduced by one level using a Move Event: Decrease Move Speed event command.

Here we go!

Coding:

Event no.1
-Create a Parallel Process event in the database.
-Add a Condition that checks if Switch “Timer Dash” is ON. Check the Else box.
-Under this Condition, add a Key Input “Input Walk”. Check the first box entitled Wait for Key Press. Check the boxes corresponding to the arrow keys (1 to 4).
-Add a Condition that checks if Variable “Input Walk” is not equal to zero. Check the Else box.
-Under this Condition, add Label 1.
-Add a Key Input “Input Dash”. Do not check the first box entitled Wait for Key Press. Check the boxes corresponding to the arrow keys (1 to 4).
-Add a Condition that checks if Switch “Dash” is ON. Check the Else box.
-Under this Condition, add a Condition that checks if Variable “Input Dash” is not equal to zero. Check the Else box.
-Under this Condition, add Label 3.
-(I added “Comment: dash” here. See picture below)
-Add a Move Event: Add 5 Increase Move Speed and 2 Decrease Move Speed. This will set the character’s movement speed to the engine’s default level.
-(I add a Wait 0.0 here but it is probably unnecessary).
-Add Switch Operation “Dash” ON.
-Add Jump to Label 1.

-Under the first Else Handler below, add Label 2.
-(I added “Comment: walk” here. See picture below)
-Add a Move Event: Add 5 Increase Move Speed and 3 Decrease Move Speed. This will set the character’s movement speed to the slower level.
-Add Switch Operation “Dash” OFF.

-Under the next Else Handler below, add a Condition that checks if Variable “Input Dash” is equal to Variable “Memory walk”. Check the Else box.
-Add a Condition that checks if Switch “Timer Dash” is ON. Check the Else box.
-Under this Condition, add Jump to Label 3.

-Under the next Else Handler below, add Jump to Label 2.

-Under the next Else Handler below, also add Jump to Label 2.

-Under the next Else Handler below, add Jump to Label 2 yet again. (There might be a simpler way to handle these three Jump to Label commands though).

-Under the next Else Handler below, add a Key Input “Input Walk”. Check the first box entitled Wait for Key Press. Check the boxes corresponding to the arrow keys (1 to 4).
-Add a Condition that checks if Variable “Input Walk” is not equal to zero. Check the Else box.
-Under this Condition, add Variable Operation “Memory walk” set equal to Variable “Input Walk” value.
-Add Variable Operation “Timer Dash” set equal to 20.
-Add Switch Operation “Timer Dash” ON.
-Add Jump to Label 2.

-Under the last Else Handler below, add Jump to Label 2.

-Put a Wait 0.0 at the very end of this event.

This first event is now done. Look at the picture below to see what it should look like:


Let’s code the second event. This one manages the time window.

Event no.2
-Create a second Parallel Process event in the database. Have it activate when Switch "Timer Dash" is ON.
-Add Variable Operation “Timer Dash” subtract 1.
-Add a Condition that checks if Variable “Timer Dash” is less or equal to zero. Do not check the Else box.
-Under this Condition, add Switch Operation “Dash” OFF.

-Put a Wait 0.0 at the very end of this event.

This second event is already done. Look at the picture below to see what it should look like:


Your “Double tap to dash” system should now work fine. This system isn’t perfect and you might stumble upon the occasional undesirable effect of having to triple tap to activate the dash, but this is only a minor issue in my opinion.
Feel free to alter this system to suit your needs.

- Avee

Posts

Pages: 1
Have you accounted for dashing into a "Move Event?" It is known to cause problems. Usually, you would use a switch to turn the entire dashing system on and off, and turn it off at the beginning of any move event that affects the player's character.

Even with that, if you somehow got the timing of the dash to end at the moment you hit the move event, you may end up retaining the dash speed while walking.

I haven't tested yours out, but I've tested simpler ones out before that didn't account for this. Just a heads up.
That's a good question.

If the player steps on a Hero Touch-activated Move Event while dashing, the player will run through the event without activating it. I tried to turn off the aforementioned switches but it didn't solve the problem.

However, setting the event to Collision with Hero will stop the player's movement, and the Move Event command will occur when you release whatever arrow key you were holding. I agree it might not be a perfect solution, but using Collision with Hero solves the event's activation issue.

Thanks for your concern :)
It won't work for me for some reason. I followed every step, and made a test map, plus an event that decreases the players move speed by 1, it didn't work. Well, whatever it is, I hope there's a good solution :3

I'm double tapping, are we suppose to hold it on the second tap. And triple tapping isn't doing anything either, do you know why?
Have you entered the exact same commands? It should work fine if so.
Make sure the two events are in the database (F8)'s Common Events tab, not in a map.
Also I uploaded this tutorial so make sure you follow the current version.

You have to tap, than press and hold.
So yes, hold it on the second tap as you say. It should work fine.

Having to triple tap is a glitch that happens sometimes and I still haven't understood why. It might have something to do with pressing two arrow keys at the same time, which messes up the coding...
I wish I didn't start a new project on RPG maker 2K.
It's very limited, and I mean VERY limited. I can't find tutorials. I want to do my Shadow game, but what's the point if I have to keep restarting over and over! Plus I just got the midis for it, so having to start over would be a real pain! I want this system, but I don't know if it's working. It doesn't seem like Shadow goes faster when I double tap, or triple tap, but it feels like it's working, in fact, I think I thought Shadow looked like he was going SLOWER than he was supposed to for about a few milliseconds!
I guess 2K and 2K3 aren't as close as I thought, RPG maker 2K3 clearly made some fixes, and I screwed up with my choice, and unless I quit, there's no other way to get around it.
This engine doesn't work at all. At least in rpg2k, and I don't understand why. My character doesn't even start running. Does anyone know of another method?
Apparently it isn't compatible with 2k. It only works in 2k3.
Can't help it.
Question: What is the "Mode Play" conditional branch switch for? Is it useful for anything? You don't mention it at the beginning of the tutorial
I can't check within the engine right now, but that "Mode Play OFF" switch seems to be used to disable the Dash system.
Since the event is a Parallel Process, it would be activated all the time. So the switch allows you to disable it in order to prevent bugs or lag.

For instance, you could turn on the "Mode play OFF" switch for the duration of cutscenes, for spending time in a custom menu or whenever the player is forbidden to dash.
Pages: 1