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:
@@ -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)
|
||||
|
||||
|
||||
## 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.
|
||||
func get_key_event(action: StringName) -> InputEventKey:
|
||||
for event: InputEvent in InputMap.action_get_events(action):
|
||||
|
||||
Reference in New Issue
Block a user