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 playerspeed = 500
const playergravity = 30
const player_jump = 700
func ready():
statemachine = $AnimationTree.get("parameters/playback")
func physicsprocess(delta):
if isonfloor():
if Input. isactionpressed("moveright"):
velocity.x = playerspeed
statemachine.travel("run")
$Sprite.fliph = false
if Input. isactionjustpressed("movejump"):
velocity.y = -playerjump
elif Input. isactionpressed("moveleft"):
velocity.x = -playerspeed
statemachine.travel("run")
$Sprite.fliph = true
if Input. isactionpressed("movejump"):
velocity.y = - playerjump
elif Input. isactionpressed("movejump"):
velocity.y = - playerjump
elif Input. isactionjustpressed("movejump"):
velocity.y = - playerjump
else:
state_machine.travel("idle")
if Input. is_action_pressed("attack_1"):
velocity.x = 0
state_machine.travel("punch")
here the preview:
https://media.giphy.com/media/j09HyRDf5y8VU1VObi/giphy.gif