33 lines
994 B
GDScript
Executable File
33 lines
994 B
GDScript
Executable File
extends SpotLight3D
|
|
|
|
var flickerWait = randf_range(1750, 2000)
|
|
var flickerWaited = 0
|
|
var moveNext = true
|
|
|
|
@onready var shrek: Node3D = get_node("../shrek_from_shrek_2_the_video_games_gamecube")
|
|
@onready var camera: Camera3D = get_node("../Camera3D")
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
visible = false
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta):
|
|
if !Globals.dead: return
|
|
flickerWaited += delta*1000
|
|
if flickerWaited >= flickerWait:
|
|
flickerWaited = 0
|
|
visible = !visible
|
|
flickerWait = randf_range(50, 1000 if visible else 75)
|
|
if moveNext:
|
|
shrek.visible = randf() < 0.25
|
|
if shrek.visible:
|
|
shrek.position.x = randf_range(-1, 1)
|
|
shrek.position.z = randf_range(0, -2)
|
|
shrek.rotation.y = atan2(camera.position.x- shrek.position.x, camera.position.z - shrek.position.z)
|
|
moveNext = 0.1 > randf()
|
|
if moveNext:
|
|
visible = false
|
|
flickerWait = randf_range(500, 750)
|