speedin-santa/Scripts/Effects/RandomColorLight.gd

17 lines
487 B
GDScript3
Raw Permalink Normal View History

2024-12-20 01:39:49 -05:00
class_name RandomColorLight extends OmniLight3D
@export var blinkSpeed: float = 5
@export var speedVariation: float = 2
@export var colors: Array[Color] = [
Color(1, 0, 0),
Color(0, 1, 0)
]
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
changeColor()
func changeColor() -> void:
light_color = colors.pick_random()
get_tree().create_timer(randf_range(blinkSpeed - speedVariation, blinkSpeed + speedVariation)).timeout.connect(changeColor)