still has bugs, but almost works like the original, but has much better structure. still might have to change around a bit, but closing in to the final form.
17 lines
481 B
GDScript
17 lines
481 B
GDScript
class_name FlashlightComponent extends Node
|
|
|
|
@export var flashlight: SpotLight3D
|
|
|
|
var flashlight_on: bool = true
|
|
var flashlight_charge: float = 100.0
|
|
|
|
func toggle_flashlight():
|
|
flashlight_on = !flashlight_on
|
|
flashlight.visible = flashlight_on
|
|
|
|
func _process(delta: float) -> void:
|
|
if flashlight_on and flashlight_charge > 0:
|
|
flashlight_charge = move_toward(flashlight_charge, 0, .2 * delta)
|
|
|
|
func _ready() -> void:
|
|
GlobalSignals.toggle_flashlight.connect(toggle_flashlight)
|