using Every x seconds

Get help using Construct 2

Post » Fri Jan 17, 2014 3:19 pm

Hi,

I need help with synchronizing the use of 'Every x seconds'. I have 2 events that trigger every 3 and 5 seconds respectively. However, when I restart the layout, sometimes the 5-second trigger off first. How do I make sure the 'Every x second' condition behaves like when I initially start the game? Do I reset the timer?

Thanks for any help rendered. Much appreciation.
B
11
S
1
Posts: 11
Reputation: 1,097

Post » Fri Jan 17, 2014 3:45 pm

I had a similar issue and I try not to use every x seconds because of it..

You could try:
if int(time) % 3 = 0 trigger event 1.
if int(time) % 5 = 0 trigger event 2.
B
20
S
6
G
2
Posts: 157
Reputation: 3,111

Post » Fri Jan 17, 2014 4:00 pm

Use the Timer behaviour. You have full control then.
ImageImageImage
B
71
S
21
G
231
Posts: 3,695
Reputation: 129,366

Post » Fri Jan 17, 2014 4:28 pm

I searched for "timer" in tutorials and found this.

https://www.scirra.com/tutorials/450/timers
B
11
S
2
Posts: 68
Reputation: 982

Post » Fri Jan 17, 2014 4:45 pm

That's out of date. Use the Timer behaviour.
ImageImageImage
B
71
S
21
G
231
Posts: 3,695
Reputation: 129,366

Post » Fri Jan 17, 2014 9:01 pm

Be aware that Every X seconds is always running as it's based on the System Time. So when you restart a layout, that timer does not reset, so if the every 5 was do to come up next, then that's what would happen. Make sense?

It's better to either 1. User the built in timer behavior or 2, create your own timer variable and add dt to it every tick. Then set it to 0 when you want it to reset.ArcadEd2014-01-17 21:01:51
B
101
S
32
G
11
Posts: 1,552
Reputation: 21,667


Return to How do I....?

Who is online

Users browsing this forum: datiel12, tarek2 and 58 guests