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

Get help using Construct 2

Post » Mon Feb 09, 2015 3:19 am

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?
B
10
S
4
G
2
Posts: 125
Reputation: 1,678

Post » Mon Feb 09, 2015 3:54 am

Overlapping and colliding do include 'touching,' as I'm sure you know. What do you want to implement it for?
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Mon Feb 09, 2015 3:56 am

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.
Moderator
B
104
S
39
G
19
Posts: 1,584
Reputation: 18,167

Post » Mon Feb 09, 2015 5:03 am

linkman2004 wrote: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.
You do not have the required permissions to view the files attached to this post.
B
10
S
4
G
2
Posts: 125
Reputation: 1,678

Post » Mon Feb 09, 2015 5:05 am

Unnatural20 wrote: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.
B
10
S
4
G
2
Posts: 125
Reputation: 1,678

Post » Mon Feb 09, 2015 8:17 am

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.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Mon Feb 09, 2015 11:19 pm

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:

Image
Moderator
B
104
S
39
G
19
Posts: 1,584
Reputation: 18,167

Post » Tue Feb 10, 2015 1:19 am

@linkman2004- 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"?
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Tue Feb 10, 2015 2:03 am

@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.
Moderator
B
104
S
39
G
19
Posts: 1,584
Reputation: 18,167

Post » Tue Feb 10, 2015 2:38 am

linkman2004 wrote:@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.
B
10
S
4
G
2
Posts: 125
Reputation: 1,678

Next

Return to How do I....?

Who is online

Users browsing this forum: CavalierBubble, Patotechnology and 19 guests