Mega Man X style dash?

Get help using Construct 2

Post » Sun May 22, 2016 7:26 am

Here's my code so far:

http://imgur.com/1SYK3lo

Basically, as long as D is held, the player automatically moves right at a higher speed. If D is not held, the speed returns to normal (180). This works well so far.

The problem is, I need the dash to last only a certain amount of time before the player has to reinitiate the dash move. If you've played Mega Man X, you'll understand what I mean. When you hold the button, X dashes forward by a certain distance before he stops and you have to do it again. He also stops short if you release the button before that time. Thanks in advance!
B
5
S
1
Posts: 15
Reputation: 341

Post » Sun May 22, 2016 7:56 am

Hi,

So you have suggested that "time" is the reason why the dash would stop, not something like stamina. Perhaps it is best to use a Counter to control this behaviour.

1) First, add an "instance variable" to the player called MaxDash.
2) To your existing function "Player_Dash" you could add "Add +1 to MaxDash". Since the function is being called 60 times a second already, giving you smooth movement, you'll find that MaxDash goes up by 60 every second too.
3) Add a "Condition" to your "Player_Dash" function that changes the code to:

On Player_Dash
If Max_Dash <180
Set speed to 500
if Max_Dash >= 120
Set speed to 180
Simulate movement Right

This way your function still operates but the player will find that their speed reverts back to 180 after 2 seconds. To reset Max_Dash you should add a line that says On "D" pressed set Max_Dash = 0. So, D being pressed resets it, D being held doesn't.
B
8
S
2
Posts: 59
Reputation: 686

Post » Sun May 22, 2016 11:58 pm

Thanks! Any other suggestions from those very familiar with Mega Man X?
B
5
S
1
Posts: 15
Reputation: 341

Post » Mon May 23, 2016 4:39 am

What about using timer to call when it ends.
Let say you press the button have it start the timer and the dash. when timer ends stop the dash.

and if button is release stop timer and dash. ?

I havent tested this yet on cause i do not currently have any project that call for dash yet.
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Tue May 24, 2016 6:28 pm

Okay, so I have it *kinda* working. I have a timer going that when it reaches a certain amount, the player goes back to their normal speed. The problem is, if the player just keeps holding D, they'll keep dashing (because the conditions for the dash are that the counter is less than "45" and that D is being held down). The timer resets after it reaches 45 and the player is still holding D, so they'll automatically be dashing again. What I can't figure out is how to make it so that the player has to hit the button again to restart the dash. Is there a way to simulate a key being released? Thanks!
B
5
S
1
Posts: 15
Reputation: 341

Post » Tue May 24, 2016 9:57 pm

what about two condition If D is down and let put in every one sec add one to a variable

If variable is greater then 5 with the condition of D is down stop dash ?

If D is release reset variable to 0 ?

You can change the variable number but this is just another idea you can try or build into.

and the variable can only be change when D is down. Does this work ?
B
52
S
24
G
6
Posts: 391
Reputation: 7,845


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests