Panst

Character Dash [HELP]

Recommended Posts

Let's see what is a dash?

I think on it as a fast increase of speed that go down again to normal speed after second or less.

 

So, when a "x" key is "just down" increase the player speed a 100% (maybe).

Example:

 

//phaser 3

//inside the update method.

var speed = 10;

if(Phaser.Input.Keyboard.JustDown(scene.mainButtoms.R)){ //I choose the buttom R to be the dash button, but could be anyone.
   sprite.setVelocityX(speed * 2);

}else if(Phaser.Input.Keyboard.UpDuration(scene.mainButtoms.R, 1000)){
    sprite.setVelocityX(speed); // or sprite.setVelocityX(0)

}

but, you have to control if the user is moving with another key, and it's change  the speed, the speed can't change until the dash is over. So you need to think how to manage that in each case.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.