Trigger events not triggering properly (such as Timer)

0 favourites
  • 7 posts
From the Asset Store
Tabata timer
$9.99 USD
Template for Tabata timer, fully documented in comments and video
  • Problem Description

    After starting timers with the same name/tag for several instances, when more than one should trigger at the same time, only the first instance is picked (and the timer event triggers only once).

    A workaround is to have a "foreach" as a "super-event" (also works as a sub-event) around the timer trigger events.

    This is curious, because if you try to put other trigger events such as "On created" or "On flash ended" inside a "foreach", it will pop up a javascript error at runtime saying that is not allowed;

    But if you do it with events such as "On timer" or "On collision with object", then not only does this not yield any javascript error, but it also produces the expected behaviour (i.e. triggers an event for each instance that it was supposed to).

    In my humble opinion, it seems to me that some trigger events are not working as trigger events at all, but rather as standard (i.e. "picking instances") events.

    Also, no answer was found here:

    Nor here:

    PS: A similar issue seems to occur with the "On collision with object" event, in the sense that if some object collides with two other objects at the same time, only one event is triggered. For most of the cases, that would not be a problem, since the instances are picked and the actions run for all of them, but in my case, I was calling a Function and passing the UID of the collided object as an argument, which results in only applying the Function to the first one. A "foreach" also resolved this problem.

    Attach a Capx



    Description of Capx

    Press each "1" button to trigger a "TimerOne" for it; Press "All" button to trigger a "TimerAll" for each.

    When "All" is pressed, you can see that the timer is set for all the "1" instances, but only triggers once, for the first one.

    When you press "1" buttons, a timer triggers correctly for each one, even when you press several very quickly.

    In the "Timer bug workaround.capx" the bug is corrected by having a "foreach" before the timer trigger events.

    Steps to Reproduce Bug

    • Start a timer with the same tag and the same duration for more than one instance of the same type;

    Observed Result

    Timer event only triggers once for some instance.

    Expected Result

    Several timer events should trigger, one for each instance for which the timer has been started.

    Affected Browsers

    • Chrome: YES
    • FireFox: YES
    • Internet Explorer: YES

    Operating System and Service Pack

    Windows 7 Service Pack 1

    Construct 2 Version ID


  • In the mean time, I suggest that you add &Self.UID (eg "timer"&Self.UID) at the end of the timer name and that you check that the timer "timer"&Self.UID is over (I agree that it should be corrected)

  • In the mean time, I suggest that you add &Self.UID (eg "timer"&Self.UID) at the end of the timer name and that you check that the timer "timer"&Self.UID is over (I agree that it should be corrected)

    Wow that's a nice hack, thanks for sharing!

    I had some questions about how to "pass parameters" to a timer in its tag, but I gave up as I would have to know the parameter value to use it as a tag (I ended up using instance variables instead) - But now you showed me a way to do it, I guess!

    But I'll stick with my "foreach" workaround for now, as I think it is cleanner (don't know if it lacks in efficiency though), and that it also solves the issue for the "On collided with object" event (by the way, I've updated the problem description).

  • This is actually by design; as you say "On timer" triggers with all the instances that have fired at the same time picked at once, and adding 'for each' is the correct workaround.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok then, it is just not that intuitive... Maybe the documentation should mention that?

    Still, it's strange that some trigger events can be put inside foreach loops and others don't.

    Thanks for the insight!

  • It also confused me, since the "On timer" has a green arrow. I would suppose that it will pick instance automatically.

  • I know this is an old thread, but I think this event should be per instance. It is not intuitive to have to put a for loop in some events and not in others.

    That said, is there any place in the documentation where you mention these kind of events? I'm finding myself adding for loops inside the events when something is not working as expected. That's how I found this problem with timers.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)