Overlapping of sprite from container with sprite from family.

0 favourites
  • 7 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hello.

    I have an issue with detecting right instance of sprite from container who overlap sprite from family and have right variable value.


    There is a lamp.

    There is a detector (or wire) in container with a lamp.

    There is a power source sprite from the family. Power source has on/off conditions. Any number of power sources can be placed on the detector.

    When detector overlaps with powered power source(atleast with one of them), the lamp turns on.

    If there is no overlap or power source is off, than lamp is off.

    Right now when powered power source overlap one of detector, all of detectors are powered. Even not connected with right power source.

    So i need help with finding the correct detector that is overlap the powered power source.

    Example project: drive.google.com/file/d/1CQOM7lY1qYWOMwRcClE3KRns1GMhRMNH/view

    LMB on power source is switching on/off state. Power source also have dragndrop behavior.

  • There are multiple mistakes in your code. You don't need to link lamps and detectors by id, they are already linked because they are in the same container. Also, "Else" with conditions that check overlapping for multiple instances will not work correctly. You need to add "For each".

    I fixed your project:


  • Thanks a lot. Your solution is work perfectly.

    I thought that if overlapping use same mechanism as a collision so detection of elements will follow the same rules.

    But i have a next level problem. Now we have 2 detectors, vertical and horizontal.

    If any of powered power source contact with any of detector connected with lamp so lamp is on. If all power is off so lamp is off too.

    And i have a situation with "For each" + "or" + "else" events that i don't know how to solve.


  • You can remove isOverlap variable, it's not really needed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for trying.

    But your solution doesn't work.


    LMB on power source - power source is on lamp is on.

    LMB on same power source - power source is off but lamp is still on.

    Lamp is off only when any power source is not overlap the detector or power source from second lamp is on.

  • You are right. Change the code like this to fix:

  • Thank you. Now everything works perfect.

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