Time Between Attacks not Getting Reset When Cancel (wrong but worked xd)

Repro:

  • In the Fighter class, we set the time between attacks by augmenting a timer every second until it gets to the designer’s desired time.

  • This timer will only be reset in the AttackBehaviour() method, which only gets called whenever the player is in the Attack State.

  • When the player is not in the Attack State, the AttackBehaviour() method will stop getting called, so the timer will remain the same.

  • If the player then decides to attack again, the timer will eventually start running, but from the time it was before until it gets restart

         -  For example: The time between attacks is 2 seconds -> Player starts attacking -> the timerstarts 
               running -> Player cancels the attack and the timer stays in 1.2 seconds -> Player attacks again 
               and the timer will start running, but now there are only 0.8 seconds to the attack to get reset.
    

Fix:

  • Set the timeBetweenAttacks variable to 0 in the Cancel() method.
1 Like

It depends on whether you want the character to wait the first time before attacking or if you want them to attack, and then wait to attack again.

Yes thank you, I was going to bring this up myself in the other video but I figured if it wasn’t bothering anyone else then it’s not important.

As is you can game the attack speed by revving up an attack, running away, then coming back to insta-slap them.

Privacy & Terms