Hello!
I am trying to set up a simple rogue-like game, and i am using a nice asset for random dungeon generation… The problem is that every tile is placed in the scene alone, even when building rooms and corridors, so i have a lot of adjacent tiles with single colliders. So i would like to know: is it possible to merge these colliders in a single one somehow?
I don’t need to have the whole dungeon walls linked with a single collider, just reduce the number of them without having one per single tile.
If anyone could help me with this issue, i would really appreciate it!
Yes, you can read all the colliders and create a combined Polygon2D collider from the others. See PolygonCollider2D in the docs, specifically pathCount and SetPath.
You cannot merge colliders. But you can use a mesh collider and them add all the dungeon walls on the mesh (procedurally generated). (Quite hard)
Create script to SendMessageUpwards just to resend OnCollision and OnTrigger events, put your script that need this calls on a GameObject and make sure that all walls is a parent of this same GO.
Do the same as described in 2 but using static functions, instead of SendMessageUpwards, to avoid the need of all walls been parent of the same GO.