Hello Guest

Author Topic: Creating Levels From Script Using Tilemaps and Tiles  (Read 3390 times)

robutmike

  • Newbie
  • *
  • Posts: 10
    • View Profile
Creating Levels From Script Using Tilemaps and Tiles
« on: December 10, 2013, 07:43:17 pm »
Hello Unikron and Friends,

I am currently trying to create a map from tiles using only scripting and prefabs. I would like to use the TileMap in TK2D for this purpose to keep my tiles well organized.  Can you please explain to me in a step by step process how I can do the following:

1. Create a tilemap that is xsize by ysize (lets say 30x30 for our example).
2. Fill every tile with a prefab tile (sprite) that I have already created in Unity or alternately create a prefab using a sprite and scripting if this is easier.

I can currently do this without using the tk2d tilemap, but would like to make the process a bit more clean by using some methods in TK2D.

I am trying to build a platformer which will create random rooms. Once I have built the tilemap and filled it with the default tiles, I will then loop over the tilemap and remove certain tiles to replace them with open spaces to create rooms.

If there is perhaps a better way to do this, I am open to suggestions.

Thank you for any help you can provide.

Much appreciated!
Mike

robutmike

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Creating Levels From Script Using Tilemaps and Tiles
« Reply #1 on: December 10, 2013, 10:08:07 pm »
FYI, I figured out how to get this to work.

I needed to create a TileMap prefab and then pass it to my MapGenerator script in the editor (which was attached to an empty "Background" object in the heirarchy). In MapGenerator, I had to have a public tk2dTileMap variable to access that slot in the Unity editor.

Just wanted to leave that info there in case anyone else is trying to figure that out.

Thanks,
RM