23 lines
726 B
GDScript
23 lines
726 B
GDScript
extends DirectionalLight3D
|
|
|
|
@onready var Player: Node3D = get_tree().get_first_node_in_group("player")
|
|
|
|
func _ready():
|
|
##Set sun positions to current time at level start
|
|
self.rotation.x = deg_to_rad(90 + (-15 * Player.current_time))
|
|
|
|
func _process(_delta: float) -> void:
|
|
pass
|
|
## 360 / 24 is 15 so make it rotate 15 degrees every hour
|
|
## subtract from 90 to offset light to start at bottom
|
|
self.rotation.x = deg_to_rad(90 + (-15 * Player.current_time))
|
|
##Reset rotation to start position after a full cycle
|
|
if self.rotation.x < -360:
|
|
self.rotation.x = 90
|
|
## Hide sun at night
|
|
##TODO Change sky so it seems like night time
|
|
if Player.current_time in range(6,18):
|
|
self.visible = true
|
|
else:
|
|
self.visible = false
|