Mega Man X style dash?

0 favourites
  • 6 posts
From the Asset Store
Fully animated top down men game asset character pack.
  • 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!

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

  • Thanks! Any other suggestions from those very familiar with Mega Man X?

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

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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 ?

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