I have 3 booleans which are each triggered by a different key press setup via the Input settings.
- When the W or Up Arrow key is pressed, tapW = true
- When the A of Left Arrow key is pressed, tapA = true
- If both tapW & tapA are true the third bool, tapAW = true
This is good and all but I would like the tapAW bool to become true only if the A key is pressed first followed by the W key (hence the bool name “tapAW”). At the moment tapAW returns true whether the combination W then A is pressed, or A then W is pressed, and I would like to trigger tapAW only when A is first followed by W. I’ve attached the relevant snippet of my simple script below. How could I do this?
public bool tapW = false;
public bool tapA = false;
public bool tapAW = false;
public bool tapWA = false;
//In the Update function
if (Input.GetButtonDown ("Walk") && !tapW) {
tapW = true;
}
if (Input.GetButtonDown ("WalkLeft") && !tapA) {
tapA = true;
}
if (tapA && tapW) {
tapA = false;
tapW = false;
tapAW = true;
}