Disable overlap collision with other objects

From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • I have a situation where I need to detect an overlap of a dagger object with randomly placed objects. The randomly placed objects do not overlap, but can be very close. It is possible for my dagger object may overlap two of these instances, but I only want one of them to have an action invoked on them.

    I was thinking of using a variable in the dagger object, which I switch to “hit” once I first detect an overlap, and then don’t process any more detections for this dagger once it is set to hit.

    I think though that when doing an ‘is overlapping‘ test, you can’t change the event selections mid way through.

    I.e only process overlaps if the dagger is not already set to ‘hit’. If I set it to ‘hit’ in the event action when the first collision is detected, will this impact the selections already made on the next overlap test in the same tick?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • could you try picking for example the top one inside the overlap check.

    I had the same thing with my solitaire game:

    youtu.be/E1zqEGLeCyI

    Here I can overlap multiple cards as well, and within the "on object clicked", I just pick the top one. I'm guessing that could be the same thing upon overlap here?

    hope this helps?

  • I got quite a nice solution working.

    I spawn a load of objects randomly, then at the start of the next tick, a While loop runs until the overlap count is zero. In the while loop positions are randomised, and the overlap check is performed and overlaps counted. A|t the top of the While loop, the overlap count is reset to zero. When it hits zero, the loop is exited.

    To avoid having infinite loops when there are a lot of objects, I count the iterations in the While loop. Every 100 iterations of randomly placing objects, I randomly remove one Balloon sprite, reset the iteration counter and continue with the process. This way I start with a large number of objects, and degrade slowly to ensure an end condition. At any point I may get lucky and the randomisation avoids overlap and I keep a large number of objects.

    I did notice that you cannot destroy objects in a While loop it seems, and not process them on the next iteration. Instead I mark them as "dispose", and ensure my overlap check ignores anything marked "dispose" by reselecting the instances at the top of each While loop iteration, and when the While loop exits....I destroy any sprites marked for "dispose"....simples ;-)

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