#[SOLVED]Need help implementing a Dash ability

1 messages · Page 1 of 1 (latest)

tepid snow
#

I'm currently implimenting a Dash action for my player and this is what I have so far. In the pastebin is my movement handling, along with both parts to my dash. Assume all variables are valid and working.

I at first tried using rigidBody.velocity = new Vector2(transform.localScale.x * dashSpeed, 0f); and it didn't work because I'm not using localScale to flip the player sprite. so I tried using .AddForce(i forgot but velocity.x * dashSpeed essentially) and it worked, but I want the player to be able to dash from a standstill, which this doesn't allow. What could I do here to give a consistent speed no matter what the state of the player is

https://pastebin.com/qQKh3rk2

#

Also, if you guys see ways to make this more.. efficient i guess? I'll always accept some help there (:

#

also for context, my movement is handled with the new Input System alone

#

It does not, nothing happens at all when trying it

tepid snow
#

I kinda hacked together a solution.

handleDash:

        if (faceDir == "Right")
        {
            rigidBody.velocity = new Vector2(dashSpeed,0);
            animator.SetTrigger("Dash");
        }
        else if (faceDir == "Left")
        {
            rigidBody.velocity = new Vector2(-dashSpeed,0);
            animator.SetTrigger("Dash");
        }
#

Move:```cs
public void Move(InputAction.CallbackContext context)
{
inputX = context.ReadValue<Vector2>().x;
if (inputX > 0)
{
faceDir = "Right";
spriteRenderer.flipX = false;
}
else if (inputX < 0)
{
faceDir = "Left";
spriteRenderer.flipX = true;
}
}