My Idle seems to override my Attack so it only plays the first frame this is my code
extends KinematicBody2D
var statemachine
var runspeed = 200
var attacks = ["attack1", "attack2"]
var velocity = Vector2.ZERO
var is_attacking
func ready():
statemachine = $AnimationTree.get("parameters/playback")
func attack():
isattacking = state_machine.travel("attack")
func getinput():
var current = statemachine.getcurrentnode()
velocity = Vector2.ZERO
if Input.isactionjustpressed("attack"):
statemachine.travel("attack")
return
isattacking = true
if Input.isactionpressed("jump"):
statemachine.travel("Jump")
if Input.isactionpressed("left"):
velocity.x -= 1
statemachine.travel("Run")
$Sprite.scale.x = -1
if Input.isactionpressed("right"):
velocity.x += 1
statemachine.travel("Run")
$Sprite.scale.x = 1
if velocity.length() == 0:
state_machine.travel("Idle")
func physicsprocess(delta):
getinput()
velocity = velocity.normalized() * runspeed
velocity = moveand_slide(velocity)