Clean/Improve my code

Godot Version

4.1.3

Question

I’m new to GDScript and Godot as a whole. I made a script for my player to be able to move and dash. It works after I’ve messed with it enough. However, it is very messy. Does anyone have suggestions for making this a little cleaner/easier to read?

Thanks

extends CharacterBody2D

@export var speed = 400
@export var dash_speed = 5000
@export var can_dash = true
var is_dashing = false 
var dash_duration = 10
@export var dash_duration_time = 10
@export var dash_cooldown = 200


func get_input():
	if !is_dashing:
		var input_direction = Input.get_vector("left", "right", "up", "down")
		if input_direction and Input.is_action_pressed("dash") and can_dash:
			velocity = input_direction * dash_speed
			is_dashing = true
		else: 
			velocity = input_direction * speed

func _physics_process(delta: float) -> void:
	get_input()
	move_and_slide()
	

func _process(delta: float) -> void:
	dash_timer()
	print(is_dashing)
	
func dash_timer() -> void:
	if is_dashing:
		dash_duration -=1
	if dash_duration <=0:
		is_dashing = false
		can_dash = false
		dash_duration = dash_duration_time
	if !can_dash:
		dash_cooldown -=1
	if dash_cooldown <=0:
		can_dash = true
		dash_cooldown = 200

Edit your post to fix the code pasted here.
Repost copy/pasted code and use the </> symbol on the toolbar and post properly formatted code here.

I was wondering about how to do this. Thanks lol

It looks good to me for a simple code. You might want to check how to use components to make games more scallable, but is not necessary for small projects.

Take a look at HeartBeast video:

I agree, it looks fine. there are no improvements possible. There is more to worry about for the rest of your game. You should move on.