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
Any help?