Events only fire for first instance?

0 favourites
  • 11 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • Sorry for the confusing title - wasn't sure how to phrase this better.

    I am having a problem where events are firing the first time conditions are met but not the second or third time.

    This post is an example of what I mean - the first instance meets the conditions and the events execute perfectly, but the second and third instances also meet the conditions and the events do not fire for them.

    I set that problem aside and tried to do something else, and it turns out that again, the conditions are met for the first instance and the events happen to fire, but for subsequent instances that meet the conditions, the events do not fire.

    Before I try to recreate this in a simpler fashion and submit a bug report, has anyone else had issues with this?

    I have tried all manners of debugging, such as using For-Each, doing a function call each time a sprite is generated, other hacky workarounds, etc. but all to no avail. I have also ran this through another experienced C2 developer and he said he has had the same issues at times and thinks it also may be a C2 bug.

  • I can assure you that picking works correctly.

    Perhaps its just the logic that's a little off.

    ID suggest instead of using pick closest you should use instance variables with a counter for each group of instances.

  • In my case, that would be a bit cumbersome but I can see it as a viable workaround.

    Is there a system expression for picking the least value when comparing instance variables? Like Pick Instance where variable X is the lowest out of the instances.

  • Only way I see to pick instance by lowest/highest value is with a for each (ordered) and a stop loop thereafter.

  • First you will have to group the instances, and the best method to do that is with an instance variable.

    You will then have to do a loop of all the groups.

    That is.... unless you go at it from the front end, or creation, where for each group you give the head a variable with the count of instances in its group, and so long as that variable is less than x amount the group may add a new instance.

    That would probably be better than the culling method.

  • I replied to the post you mentionned. It's not a picking problem, it's just that functions aren't called iteratively for each picked objects as you might think. It's one of those case where you have to explicitely iterate through your objects with a for each.

  • We've tested this, a for-each does not solve the problem.

  • Submit us your actual problem, in a simple capx.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Quickly went over your .capx:

    In your 'DestroyFurthestPart' function swap your pick conditions around. If you have pick furthest first, you will pick exactly one (possibly wrong) instance of hackpart and second condition won't really do anything. You probably want it the other way around.

  • vee41!!!!!! How the...

    You, sir, might have just fixed my problem. Those giant eyes of yours are definitely quite handy!

  • (possibly wrong)

    Most certainly wrong I'd say ! The function aims at destroying the furthest part of a particular program. The way it is right now, it destroy the furthest part only IF it is of that particular program.

    Guess you found the problem ! <img src="smileys/smiley2.gif" border="0" align="middle" />

    (Don't forget that if you keep it function embedded, you must call the function in a for each loop !)

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