::You are unable to dash because in your PMovement
script, the canDash
variable is never initialised. This means that it is false by default. Initialise it to true by default.
[Header("Dash Settings")]
[SerializeField] private float dashSpeed;
[SerializeField] private float dashTime;
[SerializeField] private float dashCooldown;
[Space(5)]
PlayerStates pState;
private float xAxis;
private float gravity;
private Rigidbody2D rb;
Animator anim;
private bool canDash = true;
private bool dashed;
Otherwise your dash condition never gets fulfilled:
void StartDash()
{
if(Input.GetButtonDown("Dash") && canDash && !dashed)
{
StartCoroutine(Dash());
dashed = true;
}
if (Grounded())
{
dashed = false;
}
}
In future, paste the codes you think have issues here so I can have a look at the code directly. It is not very convenient for me to open your project every time you run into an issue.