How do I check if two sprites are touching?not overlapping

0 favourites
  • 12 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I don't see a way to see if two sprite are just touching.

    I want two or more objects to know if they were touching, not overlapping or colliding but just idly touching, so I can create chain reactions based on the "touching" variable.

    Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Overlapping and colliding do include 'touching,' as I'm sure you know. What do you want to implement it for?

  • Your best bet would be to use "Is overlapping at offset" with a small offset, perhaps 1. This way you can have objects that aren't actual colliding or overlapping, but can determine their proximity and direction to one another.

  • Your best bet would be to use "Is overlapping at offset" with a small offset, perhaps 1. This way you can have objects that aren't actual colliding or overlapping, but can determine their proximity and direction to one another.

    Almost there!

    I still have an issue with some items that are obviously touching not actually understanding that they are... if that makes sense.

  • Overlapping and colliding do include 'touching,' as I'm sure you know. What do you want to implement it for?

    I know, it's just not working right.

    I'm working on a physics based game about matching items. I figure this is the lowest tech way possible to achieve chain reaction matches without doing loads of checking neighboring sprites.

  • I can't help but think you're having a picking problem. But I can't figure it out either.

    Mind you, lots of check-neighboring is not necessarily a bad thing.

  • You'll likely run into picking issues here, but that doesn't appear to be the case at the moment. Notice that the objects not shown as touching another object are in the bottom right of their respective groups. This is because you're only checking for an overlap towards the bottom right, so objects in the bottom right find nothing. You'll need to check for overlap in a few more directions to cover all your bases. For example:

  • Hm, that'll still miss things the same distance above/below/left/right. and for those you might want an offset of 0, 1.41 (as that's the straight-line distance of 0, 0 to 1, 1).

    Would there be a way to say "Sprite2 is X distance from other Sprite 2"?

  • Unnatural20, on the contrary, the four directions should cover the entire perimeter of any object, regardless of shape. The result is an approximately one pixel thick border of sorts around the object in question. Similarly, using offsets of (0, 1), (0, -1), (1, 0), and (-1, 0) provides coverage just as thorough, though the shape would be ever so slightly different.

  • Unnatural20, on the contrary, the four directions should cover the entire perimeter of any object, regardless of shape. The result is an approximately one pixel thick border of sorts around the object in question. Similarly, using offsets of (0, 1), (0, -1), (1, 0), and (-1, 0) provides coverage just as thorough, though the shape would be ever so slightly different.

    I'm working through the idea but I'm still getting dead zones for some reason.

  • I'm working through the idea but I'm still getting dead zones for some reason.

    Any consistent ones?

  • > I'm working through the idea but I'm still getting dead zones for some reason.

    >

    Any consistent ones?

    No, not yet.. I might end up just attaching a larger invisible sprite without the physics behavior to the main sprite and have those invisible areas check for overlap instead.

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