Stop character moving during attack animation. Using AnimationTree

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

Goodday,

When I press Attack key, the attack animation still sliding during animation event I set vector x is 0. It only stopped at moment but not after animation finish. I try to find signal at Animation Tree, but cant find finish travel states or etc. .

Here script:
extends KinematicBody2D

var state_machine
var velocity = Vector2(0,0)
var isAttacking = false

const player_speed = 500
const player_gravity = 30
const player_jump = 700

func _ready():
state_machine = $AnimationTree.get(“parameters/playback”)

func _physics_process(delta):
if is_on_floor():
if Input. is_action_pressed(“move_right”):
velocity.x = player_speed
state_machine.travel(“run”)
$Sprite.flip_h = false
if Input. is_action_just_pressed(“move_jump”):
velocity.y = -player_jump
elif Input. is_action_pressed(“move_left”):
velocity.x = -player_speed
state_machine.travel(“run”)
$Sprite.flip_h = true
if Input. is_action_pressed(“move_jump”):
velocity.y = - player_jump
elif Input. is_action_pressed(“move_jump”):
velocity.y = - player_jump
elif Input. is_action_just_pressed(“move_jump”):
velocity.y = - player_jump
else:
state_machine.travel(“idle”)

	if Input. is_action_pressed("attack_1"):
		velocity.x = 0
		state_machine.travel("punch")

here the preview: