Destroy one instance, not all

0 favourites
  • 10 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I have an object that is spawned multiple times. I would like those objects to be destroyed when the overlap another object.

    I can get the object to Destroy on overlap but the problem is -all- the objects are destroyed not just the 1 that is overlapping at the time...

    How do I do something like:

    If any instance of Object X is overlapping Object Y then Destroy the instance of Object X that is overlapping and leave the rest alone?

    I tried to use an Instance Variable Boolean and then If True Destroy Object but it still destroys all the objects not just the one that was set to True.

  • So I've tried to apply the instance variable that seemed to be working and now that everything has its own version I am seeing random objects being destroyed. going to have to dig farther... frustrating.

    Is there a really good tutorial on Instances and picking/spawning/destroying sprites with instances?

    *added: I can't seem to find anything that focuses just on this. It all seem to just sort of gloss over this part of Construct 2 like I should know what's going on from my extensive web and computer programming background that I don't have.

    I know it can't be as hard as I am making it. Construct 2 makes everything so easy -once you know how-...

    Problem is I am much too much a newbie I don't even know the proper terms to begin a search for what I need!

  • Best way to get a quick and definate answer/solution is to post up a capx file so we can see what the problem is.

    Mike at BrashMonkey

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Unforunately the problem is heavily embedded in a project that I can't share and there are lots of things controlling other things making it not so easy to pull apart for a clean version. Nor does rebuilding it makes sense...

    I did figure out my issue though... I had forgotten to increment my Instance Variable that gave each a unique ID. Once I get that in there I think this will work.

  • nope... didn't help...

    I'm not sure which would take me longer rebuilding this into a capx I can post or just figuring it out...

    I wish Copy Paste from one project into another would at least pull all the objects needed, trying to make samples of problems from big projects is so tedious...

  • I managed to brute force something I can share...

    basically I have bouncing balls controlling some sprites as emitters. The emitters check for certain collisions/overlaps and if they are in the clear they emit.

    The big emitter is dominant. It can emit on top of the small emitter. If the big emitter emits on top of a small object it goes away.

    Or at least that's the goal.

    There is probably some broken/unused stuff in the capx but I tried to get it down to just the emitter engine and what they emit.

    Yes, its 3840x1080... browser zoom is a little odd with it but I set Chrome zoom level I want, exit out, come back in and its centered better... Its an odd project!

    dl.dropboxusercontent.com/u/39000273/spawn%20destroy%20sample.capx

  • I looked at your .capx and I couldnt understand what are u trying to achieve but let me say this. The problem you described in the first post isnt because of the collisions. The spawned object arent getting destroyed randomly, they are fading away because they have the FADE behavior attached to them and it is active by default. When I deactivated the Fade Behavior the Green Spawner only spawned when it wasnt overlaping another instance and the blue one only got destroyed when the green spawned over it.

    Was that your problem?

  • Thank you for taking a look!! Its a mess, I know...

    If you watch the numbers they vanish in groups instead of fading or vanishing because of an overlap condition...

    The slow fade out is intentional. They all fade eventually or else I would never end up with more space to emit more things into!

    What I want is when the larger objects are emitted and are overlapping the smaller objects that the smaller objects go away and leave clear space for the bigger objects...

    it won't make much sense as a game thing because the project is not a game in the end...

    Currently: (not the CAPX)

    Bouncing ball controls emitter position.

    Emitter checks that it is not overlapping another emitter, an emitted object, or one of the "walls".

    If the Emitter is clear it emits a Place Holder which then get Text and other things Pinned to it.

    The larger sprites are the focus, the smaller sprites are filler.

    What I want:

    Bouncing ball controls emitter position.

    Bigger emitter emits when clear of walls and other big objects.

    Smaller emitter emits when clear of all walls and big and small objects.

    If the bigger emitter puts a big object on a smaller object I want the smaller object(s) to go away.

    The big objects should dominate the space. Any time they are ready to show up they should and everything that's smaller and in its way should Destroy.

    I hope that makes sense...

  • I haven't tried it yet but looking over your image I think I understand why it works. The Trigger Once keeps the Instance Variable change to only the object breaking the rules instead of across the whole batch.

    Unfortunately I did something really really stupid when I was saving out the CAPX and I have to redo everything I did to get to the point I was at and failing.

    Thanks for light at the end of the tunnel! Construct 2 is way outside my normal job of video engineer and you guys are so helpful!

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