matching instances

0 favourites
  • 4 posts
  • I have lots of instances of the same object and when 2 overlap and both have the same matching variable i want to destroy them. If the variables don't match i don't want anything to happen.

    I've tried multiple different variations of this sort of thing

    sprite overlap sprite

    sub event - for each sprite

    + sprite variable = 1

    destroy sprite

    This works however it still destroys 1 sprite if it has the correct variable and the other doesn't. How do i check both instances during the overlap?


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you have one of the paid versions you can use "the family trick" to do this.

    Just add the object to a family, and add a variable to both the object, and the family.

    Then when you create the object set its variable, and its family variable.

    For the collision event:

    +>object variable= your value

    -->object is overlapping family

    --->family variable = your value, do stuff


    Would it be possible to add something like is overlapping(at offset) other instance, and collision with other instance?

    While using a family works, it still seems kind of hackish.

  • I'll try that, thanks for your help.

  • I'm afraid that method doesn't seem to have worked either, unless i haven't implemented it correctly, or i haven't explained clearly what i'm trying to do. I'm sure the fault lies with me.

    This is what i'm trying to accomplish,

    sprite.instance1 overlaps sprite.instance2, and sprite.instance1 variable=1, and sprite.instance2 variable=1, then destroy both instances.

    if sprite instances have different variables then destroy neither.

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