Can an instance detect itself on overlap?

This forum is currently in read-only mode.
  • Here's what I have:

    Spider is in Family Bugs. I want Splatter to spawn only when the the Spider is destroyed and is overlapping anything in the Family Bugs. However, even if the Spider is alone, it still spawns Splatter. Is this because Construct reads the Spider as overlapping itself (because it's in the Family Bugs)? Is there a simple way around this?

    Here is my code

    [Condition]When Spider Life=0:[Event] Destroy Spider

    [Sub-condition]If Spider overlaps Bugs:[Event] spawn Splatter

    Thanks in advanced!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's being asked all the time in one form or another. Should be sticky somewhere or something I don't know.

    Add another family to your Spider sprite. Now check for overlap between those two families instead of using the sprite itself and one family. Should work like a charm now.

    So your events could look like this (while Vermin is the new family):

    [Condition]When Bugs Life=0:[Action] Destroy Bugs

    [Sub-condition]If Bugs overlaps Vermin:[Action] spawn Splatter

  • You can also have your variable comparison in the same condition with is overlapping.

  • Thanks for the quick reply. Works perfectly.

    Sorry for asking a question that's been answered many times before

    The condition here is "Sprite is overlapping another object" but logically, I think, "There is no other object!" So I'm curious as to what example is happening inside of Construct. Construct is usually very transparent (which is why it's so easy to use), but this one has me a little puzzled.

  • Hmm, this sounds like a bug. It makes no sense for an object to register as overlapping itself. Put something on the bug tracker so I don't forget about this one.

  • If an object is checking for overlap with family it is in, it doesn't check if it is overlapped the family counterpart of itself. I've made it a habit to compare the UID; only go ahead with overlap detection if the UID is different than the object's.

  • I just made a quick .cap in 0.99.5 - 'Sprite overlaps family Red', and Sprite is in family Red. The event never runs. In the runtime, I can see I have already accounted for the overlapping-self case and made sure its never run. Can someone reproduce this in a simple .cap?

  • Strange, I just did the same and it works fine.

  • I was trying to reproduce my problem again and was having trouble doing so as well. I went back into a old copy of my game and realized that the spider hit box that was always set to the spider was mistakenly in the family bugs, causing the on collision to occur all the time.

    My mistake. Sorry to throw you guys for a loop

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