Hello Guest

Author Topic: Looping through a tilemap's tiles to find out if a tile has a collider  (Read 3829 times)

dotty

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 65
    • View Profile
Hello, does anyone know how to loop through a tilemap to find out if a tile has a collider or not?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
1. Get the tileId for a tile.
2. The tileId for the tile = the sprite collection spriteId. So...
tk2dSpriteDefinition def = tilemap.SpriteCollectionInst.spriteDefinitions[tileId];
3. if (def.colliderType != ColliderType.Unset) it has a collider of some form.

dotty

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 65
    • View Profile
Yeah, after I posted this message I thought the best way would be to use getTileByPosition (or whatever the method is called), then loop it. I thought there might be an array holding all tiles and their position. I was hoping to be able to loop an array then check that tile.