Picking between instances on overlap

0 favourites
  • 4 posts
  • I'm not sure if this is a bug, or if my logic is flawed somewhere in this event. When this pink sprite overlaps a carrot, I want it to only pick 1 of them. So my event reads: Sprite Overlaps Carrot, pick 1 of them at random, however it doesn't seem to care about any picking condition that happens after the overlap and applies the actions to all instances that are being overlapped anyway.

    <img src="http://dl.dropbox.com/u/1024727/c2/picking.PNG" border="0" />

    A note: This is a subevent of a button press thing, so it can only happen once.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sounds like a bug. It should work as you described.

  • "Is overlapping" has a built-in "for each". It was the same in CC, although "overlapping at offset" just was a filter.

    If "Is overlapping" was just a filter your conditions would look like this:

    p_det | carrying=0

    p_pickup | is overlapping o_carrot

    for each o_carrot

    System | pick a random o_carrot instance

  • Oh wow that's interesting, thanks Rojo! So to make it easier for me to understand, I'm going to presume that the "for each" condition is always there after an overlap but just invisible.

    Now that I understand that, it was a simple fix in this case. I replaced the "pick random" condition with a check to see if 'pickingup' variable equaled 0, so that the event was only occurring once.

    Fantastic, thanks for you help.

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