2D top down dash code

'Ive been looking around to get a good dash code for my character and i cant get my velocity to change hoping you could help here’s my code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DashAbility : MonoBehaviour {

    public float dashCooldown;
    public bool canIDash = true;
    public Vector2 CurrentVel;
    // Use this for initialization
    void Start () {
       

    }
	
	// Update is called once per frame
	void Update () {

        CurrentVel = GetComponent<Rigidbody2D>().velocity;

        if (dashCooldown > 0)
        {
            canIDash = false;
            dashCooldown -= Time.deltaTime;
        }

        if (dashCooldown <= 0)
        {
            canIDash = true;
        }

        if (Input.GetKeyDown(KeyCode.LeftShift) && canIDash == true)
        {
            
            //this part is the actual dash itself
            CurrentVel = new Vector2(CurrentVel.x * 10, CurrentVel.y * 10);
            //sets up a cooldown so you have to wait to dash again
            dashCooldown = 2;
        }
    }
}

The problem is dashing gets overrided by movement, I guess you don’t really want to play with curves etc. so let’s keep it simple.

Instead of doing modifications in the ability which could be pretty advanced you should be fine with simple player movement rework:

public class PlayerMovement : MonoBehaviour
     {
         public float walkSpeed = 4f;
         public float runSpeed = 8f;
 
         // Use this for initialization
         void Start()
         {
            
         }
 
         // Update is called once per frame
         void FixedUpdate()
         {
             Vector2 targetVelocity = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
             if(targetVelocity.magnitude() * walkspeed > GetComponent<Rigidbody2D>.velocity.magnitude()) GetComponent<Rigidbody2D>().velocity = targetVelocity * walkSpeed; //So, dash results in higher velocity than normal movement? then let's override it only if it got slower than movement!
         }
}

This is far from perfect and you can obviously do that cpu cheaper way, but should work.