i'm using a kinematicbody2d with two sprites:hair and body. every sprite has an AnimationPlayer. i set the animations for running and the idle state. All have the same animation lenght and the animation is done frame by frame. I tried continuous, discrete and triggered but after the third loop the hair starts to be delayed and when my body is down my hair is up and so on.
This is my code:(i'm not done with the movement, but i wanted to make sure my animations work)
Update: it isn't delayed when i'm using a 1linex6columns sprite sheet, but when i use a 2linesx6columns sprite sheet it gets delayed
func physicsprocess(delta):
if Input.isactionpressed("uiright"):
velocity.x = SPEED
$body/bodyAnimation.play("rightmoving")
$hair/hairAnimation.play("right1-1")
elif Input.is_action_pressed("ui_left"):
velocity.x = -SPEED
$body/bodyAnimation.play("right_moving")
$hair/hairAnimation.play("right1-1")
else:
velocity.x = 0
if is_on_floor() :
$body/bodyAnimation.play("idle")
$hair/hairAnimation.play("idle")