Physics collisions with tiles



Howdy Gamemakers,

Is it possible to check collision with tiles in the physics world? Or is it restricted to individual objects? For example i paint the background with my tileset and check physics collisions with the various tile blocks on the fly.



You never collide with tiles directly. Instances of objects collide with other instances.
So you always need at least one instance of a physics enabled object that contains the fixtures.

It is possible to get the contents of a tile layer. You can then bind a square box shape for each non-empty position that you encounter.
The manual page on tile_get_empty has an example on how to loop through tiles in a tile layer.
Simply replace the call to tilemap_set with a few lines of code to add and bind a box-shaped fixture.
I would suggest an edge or chain shape fixture for large clusters of static tiles. My hunch is it you'd get somewhat better performance (make sure you check the accuracy of that statement), and it would probably be simpler to implement. Then again, maybe detecting connected tiles could be an extra hassle.