double tapping to dash sideways

Hey folks, im trying to get my controller to jump sideways if I doubletap the A or D keys. Right now, im using physics to drive my character otherwise, and by double tapping, I should be able to apply a higher amount of force than usual, resulting in a dash or jump if you will. That part is done already. However I cannot properly detect double taps at the moment. Here is my code:

float lastTime = -0.1f;

KeyCode shuffleLeft = KeyCode.A;

float doubleTapDelay = 0.2f;

public void Update()
	{

if (Input.GetKeyDown(shuffleLeft)) 
{
			
	if (onGround) 
	{
		if ((Time.time - lastTime) < doubleTapDelay) 
		{
			Debug.Log("Shuffle left!"); // nothing is being logged atm. Problem?
			lastTime = Time.time;
			moveLeft = true; // The player will shuffle left when next FixedUpdate is called
				
		}
	}
}
}

Its not the onGround boolean check, Ive tried removing that. Im not sure I fully understand what Im doing :stuck_out_tongue:

Any help?

Move the
lastTime = Time.time
outside of the if statement.

Of course! Thank you very much. silly mistake, but leaving it here for others to see if they have the same issue

No problem! Glad it worked for you. :slight_smile: