How do I Line Up Mid Tile Collision Polygons?

0 favourites
  • 4 posts
From the Asset Store
Each tile 64 by 64 pixels - Ultimate Tile Set for your awesome games
  • 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!

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the reply 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)