[SOLVED]Problem with unwanted collisions.

Discussion and feedback on Construct 2

Post » Wed Nov 02, 2011 12:41 am

Hi!

I try to make a tetris-like, but I've a problem, here's a picture:


The sprites, with a 32px width, come into collision, despite the fact that they move by 32px on the X axis. So I don't know why they collide!

Here a .capx of my test:
test.capx

Perhaps this is due to the platform behaviour?
What do you think?wilfryed2011-11-03 20:20:40
B
23
S
5
G
5
Posts: 112
Reputation: 4,737

Post » Wed Nov 02, 2011 1:46 am

I downloaded the capx file and validated that this is an issue. I thought it might have something to do with the physics as I ran into a similar issue around scaling of images with Box2D a couple of months ago but it looks like you are not using them at all.

I noticed that if you change the width/height to like 31.9 the issue appears to be resolved.
B
22
S
5
G
6
Posts: 57
Reputation: 4,487

Post » Wed Nov 02, 2011 2:58 am

I can't change the width/height to 31.9 ... we're talking about pixel here!

I guess it's because of collision mask, nope?
B
23
S
5
G
5
Posts: 112
Reputation: 4,737

Post » Wed Nov 02, 2011 3:04 am

Well, I've change the collision mask in this way:


And now that works!
B
23
S
5
G
5
Posts: 112
Reputation: 4,737

Post » Wed Nov 02, 2011 3:06 am

But now I've a problem with horizontal movement, because of the fact I reduce the width of the mask. :/
B
23
S
5
G
5
Posts: 112
Reputation: 4,737

Post » Wed Nov 02, 2011 3:10 am

I might have not indicated correctly what I did since I am still really new to the tool. I selected the Sprite object in the Object pane (lower right) and then adjusted the Height and Width elements under the Size properties. Not sure how that affected the sprite exactly.

Your way was pretty interesting though to affect the mask but I can see how that would mess up your key press calculations.
B
22
S
5
G
6
Posts: 57
Reputation: 4,487

Post » Wed Nov 02, 2011 3:22 am

I'm sure we should keep a round number to the width and height of the sprite, to not have a white padding between the sprite.

(Btw I guess it's strange that we can set up something like 31.9 on the main panel, and can't do that when we edit the animation.)

With the solution of reduce the collision mask I can resolve my main problem, but if I press left or right when the sprite who falls is near another sprite, then he can overlaps that sprite. I don't want that! Furthermore that causes some strange bugs:
B
23
S
5
G
5
Posts: 112
Reputation: 4,737

Post » Wed Nov 02, 2011 3:26 am

Might try turning on pixel rounding. Or make your own using int(sprite.x/32)*32.
Keep in mind 32x, 32y with the hotspot in the center will be off by 16 pixels.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Wed Nov 02, 2011 3:32 am

I got the hotspot on the bottom-left.
Turnng on pixel rounding works great to not have white padding when I try with 31.9px width/height, but not solve the problem of overlaping when I move on the left or right..
B
23
S
5
G
5
Posts: 112
Reputation: 4,737

Post » Wed Nov 02, 2011 8:27 am

Unfortunately the only way to get collisions working reliably for the platform movement is to count adjacent objects as overlapping. So two 32x32 objects positioned at (0, 0) and (32, 0) count as overlapping. I'm afraid it's just something you have to work with - if it's changed so they don't count as overlapping, some weird platform bugs start appearing.

As for a workaround, how about using a full-size collision mask, but setting the object size to 31.9 x 31.9?
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Artpunk and 12 guests