Hello.
Hopefully this thread won’t be too long, I will divide the different questions in blocks, so if you don’t want to read everything, please just try to answer one :).
-
I want to generate a 50x50 TileMap using a 2-dimensional array, that has references to the GameObjects.
I want every tile to have the height and width of 40px ( that’s also the size of the sprite I am using for each tile ).
When importing the sprite, adding it to a game object ( thus adding a sprite renderer ), it appears as only ~8px wide and tall. Where exactly can I configure, so I see it in the exact size as the actual image? -
Now secondly I don’t know the best way to implement the tile map. I read many things and my idea was to create different prefabs and put them in the tilemap array, then generate the map from it. I also need the array to be able to access each tile ( tilemap[×][y] ), otherwise I could of course just place each tile next to each other in the scene, though dynamically creating the tilemap seems like the better solution.
For a 50x50 tilemap that however means 2500 gameobjects. It won’t be a huge game, but that seems very much. There are basically 3 different prefabs for the tiles ( for my bomberman clone ). A passable tile, a non-passable tile ( that one has a collider ) and a destroyable-tile ( also has a collider on it, though the collider will be removed, if destroyed, so it becomes passable ). -
I don’t know how collision works internally, I thought of also dynamically adding the colliders, depending on the character movement. It won’t make much sense to test collision with every other collider on the map ( I don’t know if that is what unity is doing ), for each direction the player walks, there’s only 3 possible tiles, the player can collide with.
But what’s the best way to create the tilemap? I thought of somehow reusing gameobjects that do the same thing. When I implemented bomberman in java, I was just drawing the tileimages on their positions. Having a gameobject for each tile seems like a huge overhead? But I can’t just make a whole image, since the tiles aren’t static ( they will of course change during the game ). I have for example a gameobject named Tile and that has a gameobject not_passable, that contains the Sprite Renderer. When I want to “draw” things, I need to create a gameobject ( that has a transform ) with a sprite renderer, right?
Thank you guys very much in advance for taking the time. I know this topic ( tile maps ) has been the question of many threads ( I googled a lot about the topic ), but still didn’t answer all my questions.