Godot version 4.2.2
Problem
My player node moving in derection of click and start to run on double click.
I’m using InputEventMouseButton.is_double_click()
for detecting double click.
But when player is walking state, sometimes occurs bug, when double click isn;t detecting.
I’ve tried to print is_double_click
in _unhandled_input
but it prints that sometimes it’s just not working (in false state). Maybe Godot has a key sticking prevention system?
# click_hold used in different part of code
# and it doesn't seem to have a connection to the bug.
func _unhandled_input(event: InputEvent) -> void:
if (event.is_action_pressed("click")):
# check distance to click
player.mouse_pos = get_global_mouse_position()
if (player.global_position.distance_to(player.mouse_pos) >
player.non_walk_distance):
player.click_hold = true
# depending on double click
# transition to state
if(event.is_double_click()):
state_machine.Transition_to("run")
else: state_machine.Transition_to("walk")
if (event.is_action_released("click")):
player.click_hold = false