Mega man 3 slide / dash feature how to?

Hi,

So I have been trying to create a slide / dash feature like they have in for example Mega man 3 for NES. When Mega man slides in that he comes to a complete stop when the sliding is done. (Unless the player keep running forward or dash again as he of course then till run or just do another dash, you can see that in the GIF I have added.)

I wonder how I could do this?

I have tried to give the player an force impulse, but even when I just give the player an impulse the player still slows down slowly and does not come to a complete stop. I have also tried giving the player velocity and such, but I got nothing to work. So if anyone know how to do this I would love the help.

Dropbox to the GIF: Dropbox - Error - Simplify your life

My current code that have not worked.

private void Slide()
{
     this.gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(5.0f, 0),  ForceMode2D.Impulse);
     clPlayerBase.GetSet_plMovement = PlayerMovement.SLIDE;
}

I would recommend using a character controller instead.
check up the Mathf.Lerp in the scripting reference.

Here’s the example:

public class ExampleClass : MonoBehaviour {
    public float minimum = 10.0F;
    public float maximum = 20.0F;
    void Update() {
        transform.position = new Vector3(Mathf.Lerp(minimum, maximum, Time.time), 0, 0);
    }
}

what this does is, in simple words, getting from a point to another, in a certain period of time, adding like a “Smoothing” movement, like a slide. you can use if statements, and use it for your dash
or another function you want to add.

Hope this will help you a lil bit :slight_smile: