Timer set wait_time not behaving normally.

Godot Version

4.6.1

So, I’m creating a script that triggers a timer to start after I press a key, when the timer times out, it calls a function to move an object and play a sound. All of that works. The issue is that I want to feed the timer my export variable:

@export var timeBetweenMovements := 5.0

func _input(event: InputEvent) -> void:
	if event.is_action_pressed("SoundBallMove"):
		moveball()
		timer.wait_time == timeBetweenMovements
		timer.start()

func _on_timer_timeout() -> void:
	moveball()
	if movedamount < moveAmount:
		timer.start()
	print_debug(timer.wait_time)

So I have tried what is suggested in the docs.

  1. Setting wait_time before calling start().

timer.wait_time == timeBetweenMovements

  1. Calling the variable inside the start func

timer.start(timeBetweenMovements)

No matter where I call or place these, the wait time is a maximum of 3 seconds. I know this via a Print_Debug(timer.wait_time) giving me a value of 3.0

I can only manage to set the wait time in the timer by just feeding it a number when I call the function - i.e. timer.start(5.0)

So I cannot feed it my own float variable for whatever reason. I have tried a number of changes to the Timer settings in the inspector, setting the .wait_time in ready function, changing the default of the variable to 0.0 or anything really.

If I put nothing in the start func brackets, i.e. start() it just defaults back to waiting 1.0 seconds as it is set in the inspector.

I’m not sure what I’m missing and why it will only set the wait time to 3 seconds when I give it my variable.

Any help would be appreciated.:grin:

== is equality test operator
= is assignment operator

3 Likes

Bahaha, man. Just one of those days I guess. Thank you :folded_hands:

edit. next day, changed this value and it didn’t fix it. Uh oh. Decided to make a new scene and script with a new timer and variable, it works, I start thinking I really messed something up in my original script. No - I was just being extra stupid and not setting the exported variable in the inspector on the right scene i.e my main scene.

Man, I love getting back into coding :melting_face:

1 Like