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

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.