Problem with my charachters dashing

Godot Version

Version 4

Question

Hi sorry for not writing my code correctly i couldnt paste in the box

Heres my problem

I have 2d character and i want it to dash see the code bellow.

It works when character is not moving but when character is moving to either left or right the character dash half or less than amout of dash

func left_to_right_dash() β†’ void :

if game_manager.amount_dash > 0:

myutility.add_log_msg("player is dashing to right")

myutility.add_log_msg(str(game_manager.amount_dash))

animated_sprite.modulate.a = 0.5

pink_guy.modulate.a = 0.5

mask_guy.modulate.a = 0.5

ninja_frog.modulate.a = 0.5

#SPEED = 250

velocity.x = 0

velocity.x += DASH 

dashtimer.start()

#collision_shape_2d.disabled = true

collision_shape_2d.set_deferred("disabled", true)

dash_available = false

is_dashing = true

game_manager.amount_dash -= 1

game_manager.emit_signal("amount_of_dash")

else:

game_manager.amount_dash = 0

game_manager.emit_signal("amount_of_dash")

func right_to_left_dash() β†’ void:

if game_manager.amount_dash > 0:

myutility.add_log_msg("player is dashing to left")

myutility.add_log_msg(str(game_manager.amount_dash))

animated_sprite.modulate.a = 0.5

pink_guy.modulate.a = 0.5

mask_guy.modulate.a = 0.5

ninja_frog.modulate.a = 0.5

#SPEED = 250

velocity.x = 0

velocity.x -= DASH 

#position.x -= DASH

dashtimer.start()

#collision_shape_2d.disabled = true

collision_shape_2d.set_deferred("disabled", true)

dash_available = false

is_dashing = true

game_manager.amount_dash -= 1

game_manager.emit_signal("amount_of_dash")

else:

game_manager.amount_dash = 0

game_manager.emit_signal("amount_of_dash")

func _on_dashtimer_timeout() β†’ void:

SPEED = 150

animated_sprite.modulate.a = 1

pink_guy.modulate.a = 1

mask_guy.modulate.a = 1

ninja_frog.modulate.a = 1

#collision_shape_2d.disabled = false

collision_shape_2d.set_deferred(β€œdisabled”, false)

dashcooldown.start()

is_dashing_timer.start()

func _on_dashcooldown_timeout() β†’ void:

dash_available = true

label_cooling_down.visible = false

label_cooling_down_black.visible = false

func _on_is_dashing_timer_timeout() β†’ void:

is_dashing = false

We cannot read your code without indentation.

Please check out Posting guidelines in #Help channel.