I am having trouble trying to figure out how to change this value. I just want to change the value “dashTime” after I press the space bar. But it seems to only incrementally change after I press the space bar. I can’t understand how to change it so that the value will continue to change even after I have pressed the button.
if(!isGrounded() && Input.GetKeyDown(KeyCode.Space))
{
playerRigid.gravityScale = 0;
dashTime += Time.deltaTime;
if (facing_Right && dashTime<.5f)
{
playerRigid.velocity = new Vector2(playerRigid.velocity.x + speed * 3, 0);
}else if (!facing_Right && dashTime<.5f)
{
playerRigid.velocity = new Vector2(playerRigid.velocity.x - speed * 3, 0);
}
}
if (dashTime >= .5f)
{
playerRigid.gravityScale = 5;
dashTime = 0;
}