Devlog #020: Tile collider generator


Left you see the old system which uses a seperate collider for every tile. Right you see the result of the new WIP tile collider generator that generates a single collider for a group of tiles.

With physics issues driving me nuts, I found that colliders that end exactly on borders of other colliders can really mess things up. Having a single big collider for tile groups would solve this issue and also provide a process time boost because not every single tile needs to be checked for collision every frame.

I still needs to test the system thoroughly, but it already works for some simple shapes.

I'll try to explain the inner workings as simply as possible. The algorithm takes a few steps:

1. Organize the tiles of a tile group from top to bottom and left to right.

2. Start at the top left tile and check if (and where) there are adjacent tiles (above, below, left or right)

3. Store the top left point of the first tile as first collider point.

4. Go to the adjacent tile following a clockwise direction (In case of the top left tile this should be the adjacent right tile. If there is no right tile, go to the below tile).

5. Based on the previous tile that was handled and the adjacent tiles of the current new tile, save the correct collider point and move clockwise to the new tile.

6. Loop the previous step until the algorithm ended up at the top left tile again.

All outer collider points should be found this way, and a collider polygon can easily be constructed.

In my case a extension of the algorithm is needed to split the resulting collider in convex subshapes to be able to use the seperating axis theorum for collision detection.


I hope to share some nice crate physics gifs when this is done.

Get Rocket Shipment

Buy Now$8.99 USD or more

Leave a comment

Log in with itch.io to leave a comment.