How do I Line Up Mid Tile Collision Polygons?

Get help using Construct 2

Post » Fri Nov 04, 2016 1:38 am

I'm having a problem creating straight collision polygons. My problem is in the way my tile maps are designed, the collision polygon needs to cut through the center of the tile. This creates inaccurate collisions because the polygon line can never be perfectly straight.

Here is a r239 capX showing the problem: http://www.louisferina.com/games/testCollision.capx There is a sprite with the platform behavior and a tilemap with the solid behavior. No events.

  • Jump into the right wall by holding right arrow and pressing up repeatedly. Do not let go of the right arrow while jumping. (Works as expected)
  • Jump into the left wall by holding left arrow and pressing up repeatedly. Do not let go of the left arrow while jumping. (Does not work as expected)

Jumping against the left wall causes the sprite to hit the center tile collision polygon. It seems impossible to create an exact line where this would not happen. Jumping against the right wall works as expected because the border of the tile can be lined up perfectly.

It seems like there needs to be either some leniency where the sprite does not hit a collision polygon that is smaller than a 0.5 pixel difference or a way to snap collision polygons to exact pixels.

Is this a bug, an editor request or am I just missing something?

Thanks for any help!
B
79
S
51
G
39
Posts: 370
Reputation: 24,705

Post » Fri Nov 04, 2016 3:03 am

It sounds like an issue like this:
http://gamedev.stackexchange.com/questi ... wall-tiles

The tilemap object merges the collision polygons of tiles with the default box collision. The result is the right wall is probably one full rectangle so there is nothing to snag on. Usually at least, it mainly depends on which tiles are merged.
Custom polygon tiles can't be merged together so that's probably why it still trips on corners.

The link above talks about solutions that probably are mostly usable from the engine level. As a user we could post it to the bugs forum and see if there's any fix that could be done.
Other ideas could be to use a second tilemap with half sized tiles. That way you can still get that tile merging and avoid corners to snag on. There are probably some other similar ideas. If it becomes too tedious you can automate it with events. If that gets too slow then you could just run the events once after you tweak your level and copy th tilemap's json to load when you actually want to run your game.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Fri Nov 04, 2016 10:31 am

Thanks for the reply @R0J0hound. I understand the issue a little bit better now. So even if we could snap the collision polygon to exact numbers it still might not merge into one single collision box?

I will try some other solutions to work around the problem for now.
B
79
S
51
G
39
Posts: 370
Reputation: 24,705

Post » Fri Nov 04, 2016 4:23 pm

Right. It's a simple thing to merge the tiles when it's known the tile's collision polygon covers the entire tile. This is probably a flag or something per tile. Custom polygons would be more complex and slower to merge because the actual collision polygons would have to be checked. The principle purpose of the merging is a quick way to reduce the number of collision polygons.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests