Change of day and night No2

extends Node2D

@onready var light = $DirectionalLight2D

enum {
	MORNING,
	DAY,
	EVENING,
	NIGHT
}

var state = MORNING

func _process(delta: float) -> void:
	match state :
		MORNING:
			morning_state()
		EVENING:
			evening_state()
			
func morning_state():
	var tween = get_tree().create_tween() 
	tween.tween_property(light ,  "energy" , 0.2 , 20)
func evening_state():
	var tween = get_tree().create_tween() 
	tween.tween_property(light ,  "energy" , 0.95 , 20)

func _on_day_night_timeout() -> void:
	if state < 3 :
		state +=1
	else:
		state = 0 

script for changing day and night does not work

Use a procedural sky resource.

Can you tell me more?

Sorry, Im not paid enough to talk more. But the docs can tell you a lot if you spend some time to read.

1 Like