How to change gradient offset per time ( in game time)?

Godot Version

4.3

Question

this game world time

const MINUTES_PER_DAY = 1440
const MINUTES_PER_HOUR = 60
#### 1 minute in game == 0.00436332312999 in rl ,example  5minute = 0.02181661564995
const INGAME_TO_REAL_MINUTE_DURATION = (2 * PI) / MINUTES_PER_DAY

func _process(_delta: float) -> void:
	time += _delta * INGAME_TO_REAL_MINUTE_DURATION * INGAME_SPEED

i want to change my gradient offset using from 0 to 1 in 5 minute( in game time ) using gradient.sample( offset value

how should i do it?

You can use tweens, but ive never seen them be used for such a long period of time, eventhough there should be no reason this shouldnt work:

var value = 0
var five_min_time = 60*5 # enter the time here

func _tween_gradient():
	var tween = get_tree().create_tween()
	tween.tween_property(self, "value", 1, five_min_time)

func get_sample():
	return gradient.sample(value)
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.