Added a day-night cycle in tutorial
This commit is contained in:
parent
7e077a3c2e
commit
c87fa29c04
2 changed files with 23 additions and 0 deletions
|
@ -58,3 +58,6 @@ text = "Press escape to skip intro..."
|
||||||
|
|
||||||
[node name="farmland" parent="." instance=ExtResource("5_imhi6")]
|
[node name="farmland" parent="." instance=ExtResource("5_imhi6")]
|
||||||
transform = Transform3D(2.19808, 0, 0, 0, 2.19808, 0, 0, 0, 2.19808, 0, 0, 0)
|
transform = Transform3D(2.19808, 0, 0, 0, 2.19808, 0, 0, 0, 2.19808, 0, 0, 0)
|
||||||
|
|
||||||
|
[node name="OmniLight3D" type="OmniLight3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.14862, 3.45556, 24.7513)
|
||||||
|
|
|
@ -3,6 +3,7 @@ extends Node
|
||||||
@onready var mapNode = get_node("/root/tutorial")
|
@onready var mapNode = get_node("/root/tutorial")
|
||||||
var mapPath = "res://scenes/tutorial.tscn"
|
var mapPath = "res://scenes/tutorial.tscn"
|
||||||
var audio_stream_player = AudioStreamPlayer.new()
|
var audio_stream_player = AudioStreamPlayer.new()
|
||||||
|
@onready var environment = get_node("WorldEnvironment").get_environment()
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
Global.currentMapNode = mapNode
|
Global.currentMapNode = mapNode
|
||||||
|
@ -60,9 +61,28 @@ func _process(delta):
|
||||||
Global.musicUpdated = true
|
Global.musicUpdated = true
|
||||||
if Global.tutorialTimerCompleted:
|
if Global.tutorialTimerCompleted:
|
||||||
audio_stream_player.playing = false
|
audio_stream_player.playing = false
|
||||||
|
change_time_of_day()
|
||||||
|
|
||||||
|
|
||||||
func play_music(music):
|
func play_music(music):
|
||||||
audio_stream_player.set_stream(music)
|
audio_stream_player.set_stream(music)
|
||||||
add_child(audio_stream_player)
|
add_child(audio_stream_player)
|
||||||
audio_stream_player.play()
|
audio_stream_player.play()
|
||||||
|
|
||||||
|
var num = 1
|
||||||
|
var day = true
|
||||||
|
var sensitivity = 0.00025
|
||||||
|
|
||||||
|
func change_time_of_day():
|
||||||
|
if num <= 1 and day:
|
||||||
|
num = num - sensitivity
|
||||||
|
if num <= 0.05:
|
||||||
|
day = false
|
||||||
|
elif num >= 0 and not day:
|
||||||
|
num = num + sensitivity
|
||||||
|
if num >= 1:
|
||||||
|
day = true
|
||||||
|
print(num)
|
||||||
|
environment.background_energy_multiplier = num
|
||||||
|
environment.ambient_light_sky_contribution = num
|
||||||
|
$DirectionalLight3D.light_energy = num
|
||||||
|
|
Loading…
Reference in a new issue