For some reason my if statement is being ignored. Whenever I charge up my for a long enough time, it just does the normal dash, even though according to the prefab it’s true. The ignored line is at 30.
//Dash Cooldown Timer
if(DashCD > 0){
DashCD -= Time.deltaTime;
}
if(DashCD < 0){
DashCD = 0;
}
//Dash Charging Timer
if(Input.GetKey(KeyCode.LeftShift)) {
DashChargingTime += Time.deltaTime;
DashCharging = true;
}
if(Input.GetKeyUp(KeyCode.LeftShift)) {
DashChargingTime = 0;
DashCharging = false;
}
if(DashChargingTime > DashChargeTime) {
this.gameObject.GetComponent<PlayerSprites>().Charged = true;
ChargeDashReady = true;
}
else {
this.gameObject.GetComponent<PlayerSprites>().Charged = false;
ChargeDashReady = false;
}
if(Input.GetKeyUp(KeyCode.LeftShift) && DashCD == 0){
if(Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.W)) {
if (DashCD == 0) {
if(ChargeDashReady == true) { //The if statement that is being ignored
Debug.Log("Charged Dash"); //The outcome that it should go to
RB.AddForce(Vector2.up * DashSpeedVert, ForceMode2D.Impulse);
RB.AddForce(Vector2.left * DashSpeedVert, ForceMode2D.Impulse);
DashCD = DashCDTime;
ChargedDash = true;
}
else {
Debug.Log("Not Charged Dash"); //The outcome that it goes to
RB.AddForce(Vector2.left * DashSpeedVert, ForceMode2D.Impulse);
RB.AddForce(Vector2.up * DashSpeedVert, ForceMode2D.Impulse);
DashCD = DashCDTime;
}
}
}
}