Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - robutmike

Pages: [1]
1
Thanks UKS!

Basically I am making a random dungeon generator. I know how to do this a few ways, but am exploring additional options with TK2D and think it would be really convenient to use the features I love from TK2D.

What if I wanted to build several prefab dungeon rooms made of tiles and load them into the scene at random? I know how to do this with a loop, but it becomes rather tedious setting each individual tile for the various room types. I was wondering if you have any suggestions on how I could make the rooms beforehand (as prefabs) and then load them into the scene when the map is generated (assume I generate the entire map when the player comes into the dungeon). Can I somehow load them into one tilemap? Do they all need their own separate tilemaps that I will then have to align? Will having 20-30 small tilemaps at once be too computationally expensive vs one large tilemap?

Thanks again for all your help,
Mike

2
Thanks! That helped immensely.

BUT! If I want to spawn a prefab at that position that is more than 1 tile in size (say... 2 tiles tall and 1 tile wide) would that still work? Or would I need to spawn it directly at that coordinates using the getileFrac method?

EDIT: I meant specifically tileMap.GetTileFracAtPosition

3
Hello fine folks.

I am trying to figure out how to instantiate prefabs based on the grid of the tilemap. Right now I can set tiles at a particular X and Y in the tilemap using Tilemap.SetTile but I can't put prefabs into my map at positions relative to those coordinates.

So for example, lets say you have a 10 tile by 10 tile room for your platformer game map. Its totally open in the inside with a wall all the way around it. I want to put a prefab "player" object or "spikes" object etc in the room. I can't add the prefab TO the tilemap obviously, as its not a tile. However, I do want to place it in the room, without resorting to figuring out specific pixel distances if possible.

The only alternative I have found so far is to use the size of the tiles in pixels and then do some crazy multiplication mess, but I am thinking there must be an easier way.

So tell me how you do it (or how you WOULD do it).

Thanks!


4
I figured out another way to do what I needed to do.

5
As a further example:

Let's say I want to build two tiles next one another, but I only build the first one, and write a loop to find the first tile and then build a second tile to the right of the first tile's location.

I can do this manually by saying:

tileMap.SetTile(0, 0, layer, tileID); // Build a tile in the bottom left of the tilemap, at the 0,0 location
tileMap.SetTile(1, 0, layer, tileID); //Build a tile to the right of the first tile

However, if I wanted to find the first tile and then get it's X and Y in the TILEMAP not in the worldspace, I cannot find a way to do that. I want to return 0,0 for the first tile, then say something like:

tileMap.SetTile(firstTile.x + 1, 0, layer, tileID);

Does that make more sense?

Thank you,
Mike


6
I am referring to it's position in the grid of the tilemap itself.

For example, the bottom left tile on a 100 wide, 100 tall tilemap, is 0,0 and the top right tile is 99,99.

Does that make sense?

Thanks!
Mike

7
I am having trouble finding a way to get a tile's position relative to the tilemap. For example, getTile returns the sprite ID. GetTilePosition returns the position in world space. I need to get a tile's x and y position in the tilemap.

SetTile sets the tile in the tilemap in this way, not in world space.  Surely there is a way to get this position as well.

Any help would be greatly appreciated.

Thank you very much,
Mike

8
Hello,

I am trying to instantiate a blank tilemap clone into the scene, then fill it with tiles of a specific type. When I tried this before, it worked, but the tilemap prefab was actually edited permanently instead of creating a clone. So each time I generated a map, the map contained the tiles from the old map, as well as the new (with new tiles overlapping old).

Can someone explain how to do this properly? Should I not be using a tilemap except for when drawing in the editor?

Thanks,
RM

Edit: I am a fool. I was not instantiating a new tilemap. Problem solved!

9
Support / Re: Creating Levels From Script Using Tilemaps and Tiles
« 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

10
Support / 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

Pages: [1]