Fix gate-opening vibration by pulsing instead of one long effect

Siim reported the hit-vibration works but the lobby gate's rumble
doesn't. Godot's start_joy_vibration() docs call this out directly:
long single effects are unreliable on much gamepad hardware/drivers,
and recommend a short effect repeated instead. Added
Controls.vibrate_for() to do that and pointed the gate at it in place
of its single 7-second call.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MXBNaEBmrYDSMcv4NgUWtV
This commit is contained in:
2026-09-10 17:56:17 +03:00
parent 1ea4171863
commit a9440c6a43
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -11,4 +11,4 @@ func _process(_delta: float) -> void:
if Run.bear_gate_open() or DP.b("gate_unlocked_bear"): if Run.bear_gate_open() or DP.b("gate_unlocked_bear"):
bear_gate_open = true bear_gate_open = true
$AnimationPlayer.play("Gate_opening") $AnimationPlayer.play("Gate_opening")
Controls.vibrate(0, 0.5, .5, 7) Controls.vibrate_for(0, 0.5, .5, 7.0)
+14
View File
@@ -251,6 +251,20 @@ func vibrate(device: int, weak_magnitude: float, strong_magnitude: float, durati
""" % [device, int(duration * 1000.0), weak_magnitude, strong_magnitude], true) """ % [device, int(duration * 1000.0), weak_magnitude, strong_magnitude], true)
## Godot's own start_joy_vibration() docs warn that a single long effect is unreliable —
## "not every hardware is compatible with long effects; you may want to make a shorter
## effect and make it repeat instead." That's exactly what broke the lobby gate's 7-second
## rumble (the short 0.2 s hit-vibration works fine): this repeats vibrate() as short pulses
## to cover the same total duration instead of one long call.
func vibrate_for(device: int, weak_magnitude: float, strong_magnitude: float,
total_duration: float, pulse: float = 0.3, gap: float = 0.1) -> void:
var elapsed := 0.0
while elapsed < total_duration:
vibrate(device, weak_magnitude, strong_magnitude, pulse)
await get_tree().create_timer(pulse + gap).timeout
elapsed += pulse + gap
## Returns the first keyboard event bound to an action, or null. ## Returns the first keyboard event bound to an action, or null.
func get_key_event(action: StringName) -> InputEventKey: func get_key_event(action: StringName) -> InputEventKey:
for event: InputEvent in InputMap.action_get_events(action): for event: InputEvent in InputMap.action_get_events(action):