Make it so collisions don't count edge to edge?

Get help using Construct 2

Post » Tue Apr 26, 2016 8:03 pm

Is there a way to make the collisions exclude edge to edge cases?
If I have a two boxes that are 16x16 and put them diagonally to each other and check if overlap at offset y+1, it will say they overlap even though they don't overlap. :(
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

Post » Tue Apr 26, 2016 8:19 pm

You can make you own collision polygones. Double click to sprite to acces the image editor. The polygones editor is the last icon in the tools bar. Right click in the graphic field to have more actions.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Apr 26, 2016 8:33 pm

The issue isn't with editing the polygons- I know how to do that. I'm trying to figure a simple way so that edge to edge cases aren't included in the overlapping regardless of polygon shape.
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

Post » Tue Apr 26, 2016 8:51 pm

Apart from shrinking the collision polygon you pretty much need to make your own collision detection.

This is really only relevant for boxes though. If you're using a grid you can use an array to lookup collisions. Also you could do manual collision detection with integer positions. I've used that before for a retro platformer where I wanted the player to fit perfectly in passages his same size.

The sizes needed to be even, or as long as the the edges of the sprite were on integer positions you could test for a collision with:

bbright > wall.bbleft
bbleft < wall.bbright
bbbottom > wall.bbtop
bbtop < wall.bbbotom

and then objects right next to each other won't count as overlapping.

Apart from that I've done stuff like

set size of everything a little smaler
check for collisions
put the sizes back to normal

or

if the hotspots are centered you could do a compare right after the overlap condition.
abs(sprite.x-wall.x) < (wall.width+sprite.width)/2
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849

Post » Tue Apr 26, 2016 9:39 pm

This thing goes round and round, and is never detecting any overlap. Yet it collides like the birds on my windows.

https://
drive.google.com/open?id=0B1SSuCVV8v74T0hPRjVRTU5vUVk

I apology for taking you for beginner. Now it is your turn, treat as the beginner (that i am).
Explain the context where it is a problem ? Plz.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Apr 26, 2016 9:57 pm

@99Instances2Go , you're using rescaled objects, which seems to get checked differently. If you use objects scaled to their origin size, they would overlap on the edges.

@R0j0hound, thanks.. I've gone with one of those options since everything is block shaped and aligned to grids. The sprites extend further than the polygons, so bboundleft, etc, don't correspond to the polygon collision area. So I have to calculate from center of the objects.. It's working how I want it now.
Would be useful to have a choice of edge cases by default though in construct2.
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

Post » Tue Apr 26, 2016 10:19 pm

Same with a 'non scaled' object.

https://
drive.google.com/open?id=0B1SSuCVV8v74YUdleURpNVNKZWM
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Apr 27, 2016 4:48 am

@99Instances2Go you're still using scaled sprites. The pink sprites are not original size you have them 270x270 when they are actually 250x250.
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

Post » Wed Apr 27, 2016 6:19 pm

Its behaves fine with a tilemap too.

https://
drive.google.com/open?id=0B1SSuCVV8v74QXk3RnRmLVpEZXc

Not that i am happy with the movement, but this is only a simple bullet behaviour riding arround that maze.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Apr 27, 2016 7:06 pm

@99Instances2Go your tilemap polygon isn't completely to the edge. So you're not seeing the problem I am seeing.
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059


Return to How do I....?

Who is online

Users browsing this forum: Semoreh and 7 guests