Hey #construct #gamedev folks, sanity check me here: when checking for a collision against a Tilemap, is there a way to access the specific tile that was collided with?
As far as I can tell it's straightforward to get the Tilemap instance that was collided with, but not the specific tile. There don't appear to be any straightforward solutions. Even checking for an overlap is risky, as I can't know the precise collision point. Maybe if I dive into scripting? Am I missing something? #construct3
@samf I made a game jam entry where one of the core mechanic is based on tilemap collision.
There is not a straight event or action to determine which tilemap tile it collides with but with some reflexion you should be able to make it.
As example, here is how I did it: an object is falling from the top of the screen and once it collides with the tilemap, that object is destroyed.
To identify the X and Y values of the tilemap tile the collision happened, you could use that falling object position
@samf And that's how I did it. I get the falling object position - which for example could be 160px - then I will select the tile of the tilemap by dividing the falling object X position by the grid size of my whole game objects - I mean every tiles is 16x16px in my game - and then I should get the tile number of the tile the falling object collided with:
160/16 = 10
It means the falling object collided with the 10th tile on the X axis of my tilemap object
Hope this helps you out