- Home /
How to handle reverse tilemap collision efficiently ?
Hello,
I am developing a game with a 2D top-down RPG style (Zelda like if you prefer). Collisions and movements follow a classic pattern.
In a classic 2D RPG, most of the time, collisions occur between the player and the collision tiles. Therefore we can say the player evolves into the empty space.
The following map would represent a RPG where x is an empty space and o is a wall:
oooooo
ooxxoo
ooxxoo
ooxxoo
oooooo
In my case, I want to stop the player from moving when NOT colliding with x, thus allowing me to keep only the necessary tiles positions in memory. And not the 16*16 (256) tiles of a map and their associated BoxCollider2D.
How would one handle this case efficiently not having to store 256 tiles into a List minus the empty ones and creating ?
NB: To make it simple I am creating a game where a user carves its way into a 16*16 map, just like one would do in a 2d Minecraft but the outside walls are totally black.
Your answer
![](https://koobas.hobune.stream/wayback/20220612152016im_/https://answers.unity.com/themes/thub/images/avi.jpg)