'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;
}
}
}