Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | anbarasu chinna |
I am changing wait time of a timer programmatically after some amount of enemy captured by player. I confirmed timer’s wait time using debugger that the value is 0.9XX. But it has not accepted by the timer, I am getting the following error
E 0:01:03.756 set_wait_time: Time should be greater than zero.
<C++ Error> Condition “p_time <= 0” is true.
<C++ Source> scene/main/timer.cpp:83 @ set_wait_time()
Main.gd:126 @ _update_score()
Main.gd:118 @ _on_ScoreTimer_timeout()
The value I set to timer is already greater than zero. I don’t know what causes this error. Any help. Thanks in advance.
Maybe showing the code you use would help?
Ertain | 2020-10-03 16:48
Hi,
yah … show some code … maybe an integer rounding in place?
klaas | 2020-10-03 17:54
Here is the code
anbarasu chinna | 2020-10-04 00:42
This is how I change wait time of a timer. At first it is
mobTimer.stop()
mobTimer.wait_time = 250/300
mobTimer.start()
I thought, by default rounding the vale to 1, so I tried to maintain float value by
mobTimer.stop()
mobTimer.wait_time = float(250/300)
mobTimer.start()
but unfortunately the timer wait time is always 1.
anbarasu chinna | 2020-10-04 00:43
it is a integer rounding. Casting the result to an float afterwards wont help
250 / 300 = 1
float(250 / 300) = 1.0
float(250) / float(300) = 0.8333
250.0 / 300.0 = 0.8333
klaas | 2020-10-04 08:55
works well with 250.0 / 300.0 = 0.8333. Thanks.
anbarasu chinna | 2020-10-04 13:06