0 votes

I created a state machine with theses states: idle, run, jump, fall and attack.
When I press the attack button, that's what happens:
enter image description here

When the platform goes up, the player falls. When goes down, the player flies.
Here's the code of state_attack:

func state_attack(delta):
    $anims.play(anim + str(dir_sprite))
    yield($anims,"animation_finished")

    if is_on_floor():
        if abs(vel.x) > 0:
            init_run()
        else:
            init_idle()
    else:
        init_fall()

I tried to insert the gravity and moveandslide in this state, but my charactes falls really fast after que animation of the attack.

in Engine by (171 points)

I think you should share more code, because the relevant part may be where you handle the movement. I guess that player is not moving when attacking, so the position remains the same while attacking... a kinematicbody2d won't collide if you dont use one of the movement methods, so you see it flying when platform is going down (actually, the character is just staying at the same point), or falling trhough (actually, it is also just staying at the same point).

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.