how to change attack animations states which are bound to same key input?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By chris33556

i have a player character that has 2 attack types, a single punch and a combo attack. i want it that when the player is not near any objects/ or enemy AI to play the single punch. and if the player is in attacking distance , to play the combo attack.

the problem is that I dont know how to switch the attacks since they are both bound to the ‘J’ key. ive tried to change the attack when the player is in the objects ‘body_entered_area’ but it doesnt work.

I cant find any tutorials either online . thanks

:bust_in_silhouette: Reply From: purple_mage
func _on_animation_tree_animation_finished(anim_name: StringName) -> void:
        if(test == objects is in a group that can combo!  && anim_name == "Your punch"):
                   autorize the next punch !
                then nothing !

func _on_area_3d_area_entered(area: Area3D) -> void:
	test = area

You finish the animation and in the end you check if you collide with an object that has area3D or body your choice , that collide . then you check if the last animation is the punch ! and once it finish the punch it look if it will do a combo !! . i hope that will inspire you ! im just a rookie =P . hope that help and this code inspire you ! on animation is finished is a signal !