I’m trying to impliment a 3 hit combo into my game but I can’t seem to figure it out. I know the reason for this is because my code isn’t counting the variables correctly, but I don’t know how to fix this. (I’ve been following multiple guides so there is a change the code is conflicting with itself)
My code for attacks:
func _process(delta):
if Input.is_action_just_pressed(“Attack”) and current_punches == 0:
attack()
if Input.is_action_just_pressed(“Attack”) and current_punches == 1:
attack2()
func attack():
var overlapping_objects = $HitBox.get_overlapping_areas()
for area in overlapping_objects:
var parent = area.get_parent()
parent.queue_free()
attacking = true
if Input.is_action_just_pressed(“Attack”) and is_on_floor():
animation.play(“punch”)
cant_move = true
current_punches+=1
print(current_punches)
else:
animation.play(“airkick”)
func attack2():
var overlapping_objects = $HitBox.get_overlapping_areas()
for area in overlapping_objects:
var parent = area.get_parent()
parent.queue_free()
attacking = true
if Input.is_action_just_pressed(“Attack”) and is_on_floor():
animation.play(“punch2”)
cant_move = true
current_punches+=1
print(current_punches)
else:
current_punches = 0