Mysterious bug - broken timers?

Discussion and feedback on Construct 2

Post » Wed Sep 09, 2015 11:59 pm

Hi, I'm having an impossible time debugging some object behavior I set up, and I'm hoping a power user out there can point out the problem. I'm mainly looking for what's wrong with my existing setup but suggestions for alternative approaches are welcome too.

I have a "mover" sprite and a "target" sprite. For each mover, I create a target, and the mover bullets towards it. When it reaches the target, it starts a "wait" timer. When the timer expires, it moves the target to someplace random and bullets towards it again. This loops indefinitely.

The problem is, a single instance of this seems to work fine, but once I start adding more instances, they will stop working after some random number of cycles. They always seemed to stop when they reached their destination, which made me think it could be a timer problem - sure enough, if I replace the wait period with another command to go to a new position, they never stop. So, my timers are broken somehow. It's as if they just get removed without ever completing their countdown.

My question is how? Why? The logic seems straightforward. I've got a .capx here, if any of you care to check it out. Click to spawn additional movers. https://www.dropbox.com/s/tj8gctbg1tnj2 ... .capx?dl=0

Thank you.
B
38
S
11
G
2
Posts: 46
Reputation: 3,916

Post » Thu Sep 10, 2015 12:12 am

If 2 timers trigger at the same time, the c2 event system doesn't filter for them in the usual way (dunno why). So, either: add a for each loop after the on timer trigger (to cycle through possible multiple trigger objects); or ad a small random number to each timer start so that 2 don't coincide. The first option is the safest IMO.
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,188

Post » Thu Sep 10, 2015 1:26 am

Wow. Thank you! Adding a "for each mover" in the on timer event condition solved it!

That is not how I expected it to work. Construct has loads of these little quirks... but it's still my favorite tool. ;)
B
38
S
11
G
2
Posts: 46
Reputation: 3,916


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 14 guests