Problem with timers and instances (probably something to do with for each)

0 favourites
  • 3 posts
  • Hi, I always seem to have issues with making multiple things on screen behave in a timed manner, but to different times.

    I have some columns which pop in and out of the ground - each one has a timer behaviour, an instance variable called "traptimer" and a boolean variable to see if it is active or inactive - at the start of the layout I do a for each loop and set the timers to the "traptimer" instance variable. This then toggles that boolean variable on and off and stuff happens depending on its state. This works fine for one object. But as soon as I have multiple, all hell breaks loose.

    If you look at the attached example, you'll see that there are 3 columns, with their "traptimer" instance variables set to 1, 2 and 3 seconds. If you look at the objects in debug mode, that boolean is being toggled on and off at the correct rate for each of them, yet the animations are going haywire. I can't seem to find what's wrong, if anyone has a moment and could take a look it would be much appreciated. Many thanks :)

    LINK:

    dropbox.com/s/23njtqfx1bbx0fd/popup.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Don't use "Trigger once" with conditions that test multiple instances. "Trigger Once" doesn't work per instance, as long as condition is true for at least one instance, this event will not be triggered again for others.

    Change your code like this:

  • Thanks heaps Dop - that is a huge help indeed! Much appreciated :D

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