"Trigger once" and multiple instances

0 favourites
  • 10 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Hey all,

    I've recently been having some problems when using 'trigger once' when there are multiple instances of an object.

    Have a look at This simple capx.

    Basically, it's a very simple code that tells the squares to change their opacity when they hit the grey square.

    However, you will notice that the very top instance never changes its opacity. If you remove the 'for each', even stranger things happen.

    (I know I could just use 'on collision' but this is just for example purposes ;) )

    Is this a bug in C2, or just a weird side effect of 'trigger once'?

  • Maybe a bug of the SC2 engine, stuttering/skipping the top part of the code on start, since

    I added a simple "wait 1 sec" and it works.

    capx

  • whoa sqiddster, even weirder than disabling "for each":

    disable the "for each", but leave the "wait 1 sec" enabled.

    It works.

    bug?

  • I wouldn't say a bug really as all "trigger once" is run once every time the previous event changes from false to true. So within a loop i'm unsure what it should do at least I can't wrap my mind around it.

    The is overlapping is only false when none of the objects overlap, so trigger once is working as expected if the for each is removed.

    Or perhaps it is a bug. What do you think the expected behavior should be in the case of the example? Or should there be another condition like "trigger once per object"?

  • I think a 'trigger once per object' would be an excellent addition to the game.

    Right now I'm creating a board game where both the player and computer spawn units before the game starts. The trickiest part for me was creating computer spawning in a way that happens sequentially instead of spawning all of its units at once. I think a 'trigger once per object' would have made my events a lot simpler.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Excal - That's a great idea! Make sure you submit it to Ashley in the suggestions forum.

    R0J0hound - On that note, I would THINK it ought to still act accordingly for each instance (without the For Each loop). If it works mostly as it should without the Trigger Once, then all Trigger Once should do is work once PER instance if true. It doesn't make sense to stop it altogether for all instances just because ONE instance meets the conditions.

  • Yeah, something like 'trigger once per instance' would be very nice. I guess the best way to do it at the moment would be to have a trigger boolean?

  • Im not so sure a "trigger once for each instance" is such a good idea, as it will probably cause more confusion. After all it is a system condition, so it should either pick all or just the first index just like system compare does.

    Then it seems like there would be no point to add a condition to objects since a simple variable will do, or in this case compare opacity.

  • Wouldn't trigger once for each instance be same as:

    conditions

    trigger once

    • - for each object
  • let's ask the man Ashley

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