Platformer Collision at Small Sizes

Discussion and feedback on Construct 2

Post » Wed Oct 19, 2011 5:17 am

When a platformer behaviour is attached to a very small sprite box (I've specifically set it at [6, 17]), and the sprite tries to walk across angled (rectangular) platforms, it seems to get 'stuck' a lot.

It doesn't seem to happen nearly anywhere near as much as when it's using large sprites.

I've tried creating an event which changes the angle to whatever it's colliding with, to little avail. Also I've tried 'rounding off' the edges, but occasionally it gets stuck on the edge of a flat box, too.

I think this is a case of collisions being too precise when they get too small. Is there the ability to make collisions a little more forgiving at smaller levels, or would it be easier to just double the size of everything?

I'm keeping it small because I'm trying to keep the overall size of the layout down.brockatkinson2011-10-19 05:20:16
B
14
S
1
G
2
Posts: 85
Reputation: 2,810

Post » Wed Oct 19, 2011 8:36 am

You could make the collisions as a "box", meaning, all pixels in the sprite will be detected.
B
47
S
10
G
6
Posts: 455
Reputation: 8,326

Post » Wed Oct 19, 2011 2:12 pm

Can you post a .capx demonstrating this?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Thu Oct 20, 2011 3:23 am

The capx is probably not really needed, because it's just using many of the default behaviours (Platform + Solid)

Here is a quick game that I mocked up to show the problem.

And the .capx to show how it was done.

The problem is when the main sprite goes on an angled platform, which gets him 'stuck'.brockatkinson2011-10-20 03:24:47
B
14
S
1
G
2
Posts: 85
Reputation: 2,810

Post » Thu Oct 20, 2011 9:06 am

Ah, I was wrong. The bounding box collision is only for Physics and doesn't seem to make a difference. I also think the pixel detection it's being too precise. Looks like the sprite it's going up and down stairs.
B
47
S
10
G
6
Posts: 455
Reputation: 8,326

Post » Thu Oct 20, 2011 2:23 pm

Well, that's odd. If you open one of the platformer examples from the examples directory it works fine.

I didn't really design the platform behavior to work at such tiny scales. The player is only 6x11 pixels big. The platform behavior is only designed to work to the nearest pixel. So I guess the off-by-one-pixel rounding is causing the problems, which is a large amount compared to the size of the player.

TBH it's difficult to make the platform movement more precise than to the nearest pixel. I'd suggest just designing your game with larger objects instead of scaling the layer.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Thu Oct 20, 2011 3:55 pm

Yeah I figured as much. I think it's just to do with the fact that at such small scales, individual pixels matter.

I looked through the code to see if I could make it more forgiving to obstacles, but it was more like I was stabbing around in the dark. I'll just make the resources bigger.

Anyway, thought I'd let you know about the limitations (if it can even be called that).

Thanks.

Edit: I got it to work really well by speeding him up. That's really all you need, at the end of the day; speed.brockatkinson2011-10-22 18:08:36
B
14
S
1
G
2
Posts: 85
Reputation: 2,810


Return to Construct 2 General

Who is online

Users browsing this forum: Lordshiva1948, MonDieu, Yahoo [Bot] and 16 guests