How do I pick one specific object when two of the same kind are overlapping?

0 favourites
  • 6 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • Hi there,

    I know this must have a simple solution so I've already searched through the forum but I haven't found anything that helped me, so I must be doing some silly mistake.

    When 2 objects of the same kind are overlapping and both collide with an explosion sprite, I want to destroy only one of those. I've chosen to pick the closest to the explosion but it's not working.

    I've also tried using "Pick top/bottom" without success.

    I'll appreciate any helpful hand.

    Thanks!

  • I think enemy is overlapping enemy doesn´t work. You can make a second family with the same objects and check for that instead. I actually use that same thing. I have basically blocksA and blocksB as families so I can check for stuff like if blocksA is overlapping blocksB since blocksA is overlapping blocksA doesn´t work.

  • it should be working based on your conditioning there (unless the case where A overlap A doesn't work), it might be your "else condition" destroys the 2nd object as soon as the other one disappears form the screen, this happens in a matter of 1 tick or 0.015ms to us watching the screen looks instant or as both getting destroyed.

    in your conditioning what Else does is

    If A overlaps A pick nearest to XY destroy

    Else (in this format means, if A is close to XY destroy) < you don't need this or you might need a 2nd condition under else if you want for 2nd object to get destroyed at a different time.

  • The problem you have here is the first condition limits the number of picked instances to 1, you cannot then pick multiple instances further down in the event. As mentioned above with the family picking is a good way of distinguishing it from 'itself'.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the replies everyone.

    I've tried with the new family and also removing the else condition but it didn't work. Both objects keep getting destroyed at the same time.

    Am I doing something wrong here?

    Thanks for all the help!

  • Isn't the explosion going to hit both objects anyway? That means the on collision logic would work on both of the instances separately. Not sure what you're trying to do here. If you want to destroy the object being hit by the explosion then it should just be the first line of the event you have there. Surely the object being hit by the explosion is also the one nearest to the explosion so I don't understand the need for the other checks.

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