Every X seconds problem

Discussion and feedback on Construct 2

Post » Tue Jul 30, 2013 1:35 pm

Hi, I have a group with one "every 5 seconds do x" in it.

The problem is, when I want to start the 5 seconds going, the first call is usualy instant, and the second one follows very soon after. At least the first call is anywyere between 0 and 5s, the following onces are 5 seconds appart.

I have tried various methods to "start" the 5s timer when i need it to start. I have put it in a group, and tried enabling and disabling, this did not help.

I added a condition, and set that condition to true when I want the ever 5 seconds to start, but that didnt help.

So I'm a bit stuck on how to get it to start such that from point X, 5s later, the first action of the every 5 s will be called.
B
17
S
6
G
3
Posts: 370
Reputation: 3,942

Post » Tue Jul 30, 2013 1:55 pm

if you want more control, perhaps just use a variable. Add 60*dt (1 a second basically) to a variable then check when it is greater than 300 (i think thats 5 seconds) then do what you wanted to do as actions then subtract 300.
B
149
S
75
G
20
Posts: 1,791
Reputation: 22,695

Post » Tue Jul 30, 2013 3:11 pm

Another possibility is using a modulus operation, for instance if you wanted the condition to trigger every 60 seconds:

Compare Values: round(time)%60 == 0
time > 0
-> Do something
B
55
S
12
G
9
Posts: 339
Reputation: 9,564

Post » Tue Jul 30, 2013 3:39 pm

Remember game seconds are affected by framerate, that's what dt are for :D
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Tue Jul 30, 2013 3:51 pm

The new Timer behaviour gives you complete control over starting/stopping.
ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994


Return to Construct 2 General

Who is online

Users browsing this forum: AnimH01 and 8 guests