Collision detection for instances of same object

0 favourites
  • 5 posts
From the Asset Store
Detects any kind of ad blocker. Very easy implementation into already existing projects
  • I'm using the DragDrop behavior, combined with Is Overlapping event to manipulate sprites. But Construct 2 does not seem to detect collision between instances of the same object type. I have looked through the forum and tutorials that work with UID and IID, but none of these are exposed in the event dialog for me to key off. I also looked at Families but not seeing how that would help here.

    I have no problems with this when dealing with instances of two different object types though.

  • Well I never tried to same collision and if that is not working for you; you can try this. Create an invisible sprite over your object, pin it. Then compare ObjectX to ObjectY.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Generally you need to pick from the objects already in the sol, filter them if you will.

    There are a few conditions that can work as sub events, such as spites pick top most, or pick closest.

  • Thank you for this suggestion jayderyu. It is the solution I picked, and this is how I went about it.

    I have two different sprite objects based on the same image. I make one invisible. When I create a new instance of the visible object, I also create an instance of the invisible counterpart and pin it to the visible sibling. I set the z-order of the invisible instance to bottom so the visible instance is always pickable. I added an 'siblingId' instance variable to the invisible object on which I set the UID of the visible instance.

    On the drop event of the visible instance, I check that it's UID is not the same as the stored ID of the receiving invisible instance, and this prevents false positive trigger of the visible instance colliding with its own invisible sibling.

    To properly clean up the invisible instance when the visible sibling is deleted, I set up an On Destroy system event for the visible object, and do a for each loop on the invisible objects, and destroy the one whose instance variable matches the UID of the just deleted visible instance.

    FWIW, I also tried the container approach, but the collision detection wasn't consistent. I might explore that a bit more at a later time.

  • I cant get this to work. i, trying to get eqch tile placed to check cpllisions on itself to see if it is the top most tile. if so set the animation frame to the top tile frame.   Im trying to use to use a container to create the duplicate sprite and am having odd results. Each tile sprite successfully creates a duplicate and pins it to its location. But when checking collisions between tile and tile duplicates at offsets , it just seems like it randomly sets tiles to "top tile" even if they haven't collided.

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