From a35dffc622bed93d01865b4730fc70b9a1fd2830 Mon Sep 17 00:00:00 2001 From: dukegoobler <76922012+vengefulcartographer@users.noreply.github.com> Date: Fri, 30 Dec 2022 15:17:26 -0700 Subject: [PATCH] subtle flashlight flicker --- godot/effects/player/Flashlight.gd | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/godot/effects/player/Flashlight.gd b/godot/effects/player/Flashlight.gd index d13ad00..f6ed7d9 100644 --- a/godot/effects/player/Flashlight.gd +++ b/godot/effects/player/Flashlight.gd @@ -1,5 +1,19 @@ extends SpotLight +var timer = null + +func _ready(): + randomize() + timer = Timer.new() + timer.wait_time = rand_range(0.1, 0.2) + timer.connect("timeout", self, "on_timer_timeout") + add_child(timer) + timer.start() + +func on_timer_timeout(): + timer.wait_time = rand_range(0.05, 0.15) + self.light_energy = rand_range(1.25, 1.5) + func _input(_event): if Input.is_action_just_pressed("toggle_flashlight"): toggle()