GODOT 4.4
Replace this line with your Godot version
how do i make the animation of my dash work ? Anytime i try, it just doesn’t show up. I’m i doing anything wrong ( sorry if i did a stupid thing i’m really new to that kinda stuff ) thx in advance !
if Input.is_action_just_pressed("dash") and dash_key_pressed == 0 and dash_number >= 1:
dash_number -= 1
dash_key_pressed = 1
dash()
if direction > 0:
animated_sprite.flip_h = false
elif direction < 0:
animated_sprite.flip_h = true
if is_on_floor():
dash_number =1
if direction == 0:
animated_sprite.play("Idle")
else :
if Input.is_action_pressed("course"):
animated_sprite.play("Run")
else :
animated_sprite.play("Walk")
else:
animated_sprite.play("Jump")
if is_dashing == false:
if direction:
velocity.x = direction * walk_speed
else:
velocity.x = move_toward(velocity.x, 0, walk_speed)
if Input.is_action_pressed("course"):
walk_speed = sprint_speed
else :
walk_speed = 300
move_and_slide()
func dash():
if dash_key_pressed ==1:
animated_sprite.play("Dash")
is_dashing = true
else :
is_dashing = false
if !animated_sprite.flip_h :
velocity.x = dash_speed
dash_started()
if animated_sprite.flip_h :
velocity.x = -dash_speed
dash_started()
func dash_started():
if is_dashing == true:
animated_sprite.play("Dash")
dash_key_pressed = 1
await get_tree().create_timer(0.2).timeout
is_dashing = false
dash_key_pressed = 0