I have a simple two chain combo attack that can be performed while the player is crouching, but the second attack won't go through.

var isCrouching: bool = false;
var isAttacking: bool = false;

var stateMachine;
var velocity: = Vector2();
        
func _ready():
	stateMachine = $AnimationTree.get("parameters/playback");
        
func input():
	var currentAnimState = stateMachine.get_current_node();
        
#CROUCH
	if is_on_floor() and Input.is_action_pressed("crouch") and velocity.y == 0 and !isAttacking:
		isCrouching = true;
		$CrouchCollision.disabled = false;
		$BodyCollision.disabled = true;
		stateMachine.travel("Crouch");
	else:
		isCrouching = false;
		$CrouchCollision.disabled = true;
		$BodyCollision.disabled = false;
        
	#Crouch light attacks
	if Input.is_action_just_pressed("light_attack") and isCrouching and !isAttacking:
		isAttacking = true;
		stateMachine.travel("AttackCrouchLight1");
	elif Input.is_action_just_pressed("light_attack") and currentAnimState == "AttackCrouchLight1" and isCrouching and isAttacking:
		stateMachine.travel("AttackCrouchLight2");
    
func attackEnd():
	if isAttacking == true:
		isAttacking = false;

Upon testing it, my crouch collision hitbox becomes disabled while the first attack is happening, so I'm pretty sure it has to do with that, but I'm not entirely sure how to go about fixing it.

I would maybe try seeing if you can figure out what part of the conditions is causing the second attack not to go through. I would try making a backup of the code (so you don't lose anything if something goes wrong) and then slowly start disabling or printing each of the values in the condition to see which is false when it should be true.

For example, maybe try printing isCrouching to see if, after the first attack, it suddenly becomes true. If it does, then you may need to add additional conditions so isCrouching is true for the entire duration of a crouch attack regardless if the button(s) are pressed or not, or perhaps have the condition only check if the first attack was a crouch attack and just assume that, if the player hits attack again, they are crouching. (Or some other solution! It really depends on the project and code)

I'm not sure if it's the best way to go about trying to fix the issue, but it's what I would try to do. There are probably better ways though :sweat_smile:

@TwistedTwigleg said: For example, maybe try printing isCrouching to see if, after the first attack, it suddenly becomes true. If it does, then you may need to add additional conditions so isCrouching is true for the entire duration of a crouch attack regardless if the button(s) are pressed or not, or perhaps have the condition only check if the first attack was a crouch attack and just assume that, if the player hits attack again, they are crouching. (Or some other solution! It really depends on the project and code)

I tried printing it and yeah, 'isCrouching' becomes false while the attack is playing. Not sure what other kind of checks I would need for that. Looking back at the code, I think it has to do with the 'isAttacking' check, since that becomes true once the attack happens.

Alright, figured it out! What I've done was add an extra bool called 'crouchAttack' and then have the crouch check for either that or 'isAttacking.' Relevant code is:

var isCrouching: bool = false;
var crouchAttack: bool = false;
var isAttacking: bool = false;

func _physics_process(delta):

#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;
	else:
		isCrouching = false;
		$CrouchCollision.disabled = true;
		$BodyCollision.disabled = false;

#Crouch light attack
	if Input.is_action_just_pressed("light_attack") and isCrouching and !isAttacking:
		isAttacking = true;
		crouchAttack = true;

func attackEnd():
	if isAttacking == true:
		isAttacking = false;
	
	if crouchAttack == true:
		crouchAttack = false;

Awesome! I'm glad you were able to find a solution :smile:

a year later