Hello, I am trying to create a timer that will reset the player’s combo back to the first attack of the combo when the player doesn’t press the attack button again within a set time while in the middle of the combo. I’ve been trying to make a coroutine work for this but it is becoming rather messy with either a ton of variables. Is there a better way to do something like this than using a coroutine?
Example of what I’m after:
Attack button pressed >
combo started with the first attack >
wait for 2 seconds >
press attack button again before 2 seconds have pasted >
combo does NOT reset and the 2nd attack is called >
wait for 2 seconds >
combo resets to the first attack
you can use the update function
float t = 0;
int combo = 0;
void Update () {
if (t > 0) {t -= Time.deltaTime;}
if (Input.GetKeyDown ("space")) {
if(t>0){combo++;}else{combo=0;}
t = 1f;
print ("number of presses:"+ combo);
}}