0 votes

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("right
moving")
$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")
in Engine by (90 points)
edited by

I don't know much about animation in the engine. But the delay could be down to one starting, and then, once that first animation is properly started, the next one is started. So how do you start them at the same time? I don't entirely know how to tackle this problem.

You may have to rely on signals. Have the animations hear for a signal. That may start them at the same time. There's that, or you may have to put the hair and body animations together into one AnimationPlayer, and have that start when your character moves.

Hello! I tried signals, and is still delaying. I don't want to have 2 animations into one Animation Player, because you as a player can customize your character so the only solution i know for this is having a lot of animations for every hair. Maybe you know another solution.(like changing the value of the line inside the code, because on my first row will be a purple hair,second row-blue hair etc. I'm using a sprite sheet)

Alright so
For those who have the same problem as me:
For me it works only if you have 1 line, and if you want to change the color, save a sprite sheet for every color of the hair and then just change the texture in code. I'm still waiting for a better solution, but until then i guess i will have to settle down with this.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.