From 782e24e411976d3bb93250f6379cd486663d013e Mon Sep 17 00:00:00 2001 From: teatov Date: Sat, 2 Aug 2025 11:52:07 +1000 Subject: [PATCH] add shaking when changing configuring state --- scripts/game_key.gd | 19 +++++++++++++++++++ scripts/second_order_dynamics.gd | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/scripts/game_key.gd b/scripts/game_key.gd index 5ae149b..393649b 100644 --- a/scripts/game_key.gd +++ b/scripts/game_key.gd @@ -103,6 +103,9 @@ func _unhandled_input(event: InputEvent) -> void: if event.is_action_pressed("reset_animations"): _reset_animations() return + if event.is_action_pressed("toggle_configuring"): + _shake(0.1) + return if event is not InputEventKey: return @@ -326,6 +329,22 @@ func _animate_position() -> Vector3: return new_position +func _shake(force: float) -> void: + _pos_sod.set_y( + ( + position + + ( + Vector3( + randf_range(-force, force), + randf_range(-force, force), + randf_range(-force, force) + ) + * keyboard.key_size + ) + ) + ) + + func _animate_light(delta: float) -> void: if _is_pressed: _light_timer = _light_fade_time diff --git a/scripts/second_order_dynamics.gd b/scripts/second_order_dynamics.gd index 738b2a1..e5b027a 100644 --- a/scripts/second_order_dynamics.gd +++ b/scripts/second_order_dynamics.gd @@ -49,3 +49,7 @@ func process(t: float, x: Vector3, xd: Vector3 = Vector3.INF) -> Vector3: _y = _y + t * _yd _yd = _yd + t * (x + _k3 * xd - _y - _k1 * _yd) / k2_stable return _y + + +func set_y(y: Vector3) -> void: + _y = y