Got a weird issue here and I really don't know how to fix it. My player has a handful of different attack moves and the ability to crouch. If the player spams the crouch and attack buttons so that they constantly go in and out of a crouch and throw out attacks, the 'isAttacking' check I have gets permanently stuck to 'true,' and the player is unable to do almost anything because of it. They get stuck in their idle animation and the only action they can perform is going in and out of a crouch.
Crouch code:
#CROUCH
if is_on_floor() and Input.is_action_pressed("crouch") and velocity.y == 0 and (!isAttacking or crouchAttack):
isCrouching = true;
$CrouchCollision.disabled = false;
$BodyCollision.disabled = true;
animState.travel("Crouch");
else:
isCrouching = false;
$CrouchCollision.disabled = true;
$BodyCollision.disabled = false;
Standing attacks (I think it's just these, I can post the crouch attack code if needed):
#Standing light attacks
if Input.is_action_just_pressed("light_attack") and is_on_floor() and !isCrouching and !isAttacking:
isAttacking = true;
if Input.is_action_pressed("interact"):
animState.travel("AttackLightUp");
else:
animState.travel("AttackLight1");
elif Input.is_action_just_pressed("light_attack") and currentAnimState == "AttackLight1" and is_on_floor() and !isCrouching and isAttacking:
animState.travel("AttackLight2");
elif Input.is_action_just_pressed("light_attack") and currentAnimState == "AttackLight2" and is_on_floor() and !isCrouching and isAttacking:
animState.travel("AttackLight3");
#Standing heavy attacks
if Input.is_action_just_pressed("heavy_attack") and is_on_floor() and !isCrouching and !isAttacking:
isAttacking = true;
if Input.is_action_pressed("interact"):
animState.travel("AttackHeavyUp");
else:
animState.travel("AttackHeavy1");
elif Input.is_action_just_pressed("heavy_attack") and currentAnimState == "AttackHeavy1" and is_on_floor() and !isCrouching and isAttacking:
animState.travel("AttackHeavy2");
For combos (these are called at the end of the animations):
func attackEnd():
if isAttacking == true:
isAttacking = false;
if crouchAttack == true:
crouchAttack = false;
Another weird thing is that it should be set so that the player is unable to do anything until the attack animation is finished (hence the 'attackEnd()' function) unless they perform a combo attack and this usually works pretty well, but for some reason, if the player rapidly spams the crouch button, it bypasses that somehow, skipping any attack animations entirely. I'm pretty sure this is why 'isAttacking' gets stuck to true (attack animation never finishes so 'attackEnd()' is never called), but I have no clue how to fix it.