I've recently bought Tidy Tilemapper, and I am now trying to create a procedural tile world with it. All I want is to remove any tiles too far away to be useful, and only show those close to my character. For testing purposes I have been using arbitrary numbers...
What I do (or am trying to do) is create a radius where I check all tiles within. I then have a smaller radius within that, and I remove everything there's outside the small radius, and inside the big radius. This way I avoid accessing the rest of the map, outside the big radius. Everything inside the small radius should be drawn to the screen. At the moment my map is pretty simple, if the value in the 2 dimensional array is 1, it should draw something.
When I launch the Scene I make the player a child of the Blockmap that is created. I then compare localPosition values to the position of the blocks. I think this is here my problem starts - Everything tile(block) that is created, are created towards the negative direction of Worldspace (and local space). I've messed around a lot with the following code on that account (I've burned out my brain :P). I'm spawning my player at X=0, and Y = half the height of the map. While I fall down to the map, if I move out in the positive direction on the X-axis (off the map) it will actually remove some of the tiles that it is supposed to. But it does not redraw any of them. If I move around on the world that is created for testing purposes, it does not remove anything in the "large radius", and doesn't create anything either.
I've taken the Perlin and level generation examples that are included in Tidy Tile Mapper, and modified them.
First off the Start and update methods, just so you can see the order of things. ConstructInitialWorld method prepares the Block Map, and creates the int array containing the map via the GetLevelMap method.
My guess is the problem is in the following code:
I know this is a heavy read, and thanks for reading it- But I really hope someone has an idea or can actually see what I am doing wrong.
Here's a link to a little documentation for Tidy TileMapper http://tools.dopplerinteractive.com/
I don't have this toolkit, but it seems that it's already managed in chunks, so basically you should create / delete whole chunks instead of manipulating single block in those chunks...
It's actually very similar to the concept of minecraft ;) Just in case you haven't seen this yet, there is a free Minecraft starter package for Unity3d.
answered May 02 '12 at 01:26 PM
Nice, I will look into that package. I've already thought of operating in chunks, but there doesn't seem to be out of the box methods to add or remove chunks. But whether I figure out to handle it chunkwise or not, I'm still ending up with the same issues with my algorithm :)
Nice, thanks a lot for the link, I'll check it out.
I have already considered working in chunks, but I it seems there are no "out of the box" add or remove methods for chunks. I will probably do a method for this later, but this will not fix my currently bugged algorithm, that I've stared myself blind on :)
Thanks for the hints, I'll definately check out the Minecraft kit.