Skip to content

Commit b005ff9

Browse files
authored
HookControl: Disable keyboard aiming while mouse is in use (#2101)
Use a 3 seconds timeout to resume aiming with keyboard. This also happens to be the amount of seconds we keep the mouse cursor on screen in the MouseManager. This fixes an error in which the mouse and keyboard are competing for the aiming direction, making the grappling hook very hard to use. Credits for this feedback goes to Heather Drolet who complained about this in a playtest. ## MouseManager: Do not hardcode wait_time in code For hiding the mouse. The timer is already configured to wait 3 seconds.
1 parent ced4bc9 commit b005ff9

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

scenes/game_elements/props/hook_control/components/hook_control.gd

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ var _hook_angle: float
8787
## diagonal directions when releasing the input actions.
8888
@onready var d_pad_timer: Timer = %DPadTimer
8989

90+
@onready var mouse_aiming_timer: Timer = %MouseAimingTimer
91+
9092

9193
func _unhandled_input(_event: InputEvent) -> void:
9294
if _event is InputEventMouseMotion:
95+
mouse_aiming_timer.start()
9396
var axis := get_global_mouse_position() - global_position
9497
if not axis.is_zero_approx():
9598
_hook_angle = axis.angle()
@@ -102,7 +105,8 @@ func _unhandled_input(_event: InputEvent) -> void:
102105
# there is always one that is released first so the aim direction ends up being either left or
103106
# down, not left AND down.
104107
if (
105-
_event is InputEventKey
108+
mouse_aiming_timer.is_stopped()
109+
and _event is InputEventKey
106110
and (
107111
_event.is_action_released(&"aim_left")
108112
or _event.is_action_released(&"aim_right")
@@ -113,7 +117,8 @@ func _unhandled_input(_event: InputEvent) -> void:
113117
d_pad_timer.start()
114118
return
115119

116-
_update_hook_angle()
120+
if mouse_aiming_timer.is_stopped():
121+
_update_hook_angle()
117122

118123
if Input.is_action_just_pressed(&"throw"):
119124
pressing_throw_action = true

scenes/game_elements/props/hook_control/hook_control.tscn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ unique_name_in_owner = true
2222
wait_time = 0.2
2323
one_shot = true
2424

25+
[node name="MouseAimingTimer" type="Timer" parent="." unique_id=405211158]
26+
unique_name_in_owner = true
27+
wait_time = 3.0
28+
one_shot = true
29+
2530
[connection signal="timeout" from="DPadTimer" to="." method="_on_d_pad_timer_timeout"]

scenes/globals/mouse_manager/mouse_manager.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func _ready() -> void:
2020
func _input(event: InputEvent) -> void:
2121
if event is InputEventMouseMotion:
2222
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
23-
hide_timer.start(3)
23+
hide_timer.start()
2424

2525

2626
func _on_hide_timer_timeout() -> void:

0 commit comments

Comments
 (0)