Tidy Tile Mapper‎ > ‎Runtime API‎ > ‎BlockUtilities‎ > ‎


Returns the MapChunk at the given Block coordinates. 

Useful in niche cases.

I'll provide the one nice instance that I have used in the example below.

It is also useful to be able to fetch the MapChunk at 0,0,0 in order to orient maps to your camera nicely.
I'll leave the logic there to you, the mathematics are much too long for this little grey example box.

To provide you with an understanding of how this works:

If you have a chunkWidth and chunkHeight of 5 and 5 respectively, then queries to GetChunkAtCoordinates() with arguments between 0...4 will return the same MapChunk (as this is the MapChunk hosting the Block coordinates provided).


MapChunk GetChunkAtCoordinates(BlockMap map, int x, int y, int depth)

Return value Description
MapChunk The MapChunk at the Block coordinates you have requested, null if none exists. I don't recommend you perform operations on the MapChunk itself, there is voodoo within it. Use it for its handy Transform component.

Argument DataType Description
map BlockMap The map from which you wish to fetch the MapChunk.
x int The x Block coordinate of the MapChunk you wish to retrieve.
y    int The y Block coordinate of the MapChunk you wish to retrieve.
depth int The depth (z) Block coordinate of the MapChunk you wish to retrieve.


This is an exceptionally handy little sample - this will retrieve a chunk from the given Block coordinate, check if it is empty, and if so - remove it from the map. 

Use this judiciously (i.e only if you are 100% confident that this is what you want).

The use-case I have in mind is for an 'infinite runner' style of map generation - where we will be quickly moving through many chunks and don't wish to leave a billion empty chunks in our wake.

This function is not integrated internally into the toolkit, as it is very use-case specific.

MapChunk chunk = map.GetChunkForBlockCoordinate(x,y,z);

if(chunk != null){
  if(chunk.chunkPieces != null){
    for(int i = 0; i < chunk.chunkPieces.Length; i++){
      if(chunk.chunkPieces[i] != null){