0 votes

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 "ptime <= 0" is true.
<C++ Source> scene/main/timer.cpp:83 @ set
waittime()
Main.gd:126 @ _update
score()
Main.gd:118 @ onScoreTimer_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.

in Engine by (110 points)

Maybe showing the code you use would help?

Hi,
yah .. show some code ... maybe an integer rounding in place?

Here is the code

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.

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

works well with 250.0 / 300.0 = 0.8333. Thanks. :)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.