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 theCancel()
method.