Please try to avoid posting just to bump a topic if possible.
What have you tried since you last posted? Is the issue with the animations still present? If you can, giving an update on the situation, the issue(s) still present, and the solutions tried can help with finding potential solutions.
Looking at the code, the issue is likely other animations, like the idle animation, overriding the attack animation before it has a chance to fully play. The collision shape(s) for the attack are stilling being enabled and disabled, which means at the very least that some part of the attack animation is playing. It seems the only part of the attack animation that is not playing is the visuals.
You'll probably need to write the code so that when the attack animation is playing, no other animation can play. There are several ways to do this, but the easiest is to "lock" the animation until it is done playing.
Something like this should work (untested):
var body_animation_locked = false
func _ready():
# Connect the animation finished signal...
$body.connect("animation_finished", self, "_on_body_animation_finished")
func _play_animation(animation_name, lock_animation=false):
if (body_animation_locked == false):
$body.play(animation_name)
body_animation_locked = lock_animation
func _on_body_animation_finished(animation_name):
body_animation_locked = false
Then you could just replace stuff like $body.play("knife_melee")
with _play_animation("knife_melee", true)
, which should allow the entire knife animation to play before changing to another animation.
There are other ways to do it as well, like using a state machine, but that is probably the easiest way to go about it. Hopefully this helps.