if Input.is_action_just_pressed("forward") or Input.is_action_just_pressed("backward") or Input.is_action_just_pressed("left") or Input.is_action_just_pressed("right"):
dash_count += 1
if dash_count == 2 and dash_timer < double_press_time:
horizontal_velocity = direction * dash_power * 2.5
This checks if the the movement inputs are being pressed, if yes... gain one 1 point in dash count... dash count returns to zero after 0.3 seconds
if dash count is 0, you can't dash... if dash count is 2, your character will dodge/dash in the direction of movement.
The system exists to allow dodging by simply double pressing the movement keys... but I also realized that is quite easy to dodge by mistake by simply switching directions....
How do I fix this without creating a different timer for every single input? Also I tried reducing the dodge timer, but after testing it with my brother, I realized around 0.25 and 0.3 seconds is the safest as even a child can manage to dodge correctly with this timer.
old_move_dir
). I was using the dot product (move_dir.dot(old_move_dir) > 0.0
) to allow the player to change direction while retaining the speed, but not do a half turn. I suggest you revisit that idea. You, of course, could me more restrictive than that if you need to. \$\endgroup\$