How to change a timer wait time during gameplay?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mystoquente

I have a timer in my Main scene and I want to be able to change its wait time according to how fast the game is. So I attached a script to this ObstacleTimer and I wrote:

extends Timer

func _change_wait_time():
	if TimeManager.VELOCITY >= 5.5:
		Timer.wait_time = 1.0
	elif TimeManager.VELOCITY >= 3.5:
		Timer.wait_time = 2.0
	else:
		Timer.wait_time = 3.0

func _process(delta: float):
	_change_wait_time()

This give me the following error:

Invalid set index 'wait_time' (on base: 'GDScriptNativeClass') with value of type 'float'.

I tried changing from float to int, but it gives me a similar error:

Invalid set index 'wait_time' (on base: 'GDScriptNativeClass') with value of type 'int'.

Can anyone help me solve this?

:bust_in_silhouette: Reply From: umma

instead of timer.wait_time = 1.0 try this self.wait__time = 1.0

1 Like