Hack Forums
[C#] Infinite 2D tile base world - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Infinite 2D tile base world (/showthread.php?tid=5257223)



Infinite 2D tile base world - Nyreo - May 2, 2016

Hey, I am just messing around with unity and trying to make a game and I can't seem to figure out how I could make a 2D infinite world. I current have an object that spawns individual tiles of the terrain so that it will fill the view port of the main camera which works fine; however, when I reach the end of the generated tiles then it just stops. I thought that you could do it by using the movement of the player and if the player moves up by one tile then it removes the tiles that were previously displayed and add them to the top of the camera but then if the player went back then it wouldn't be generated the same, that would work with a single terrain tile but when I start adding new terrains i'm guessing it wouldn't work.

So I was just wondering if anyone here had any ideas on how this could be done effectively?

Thanks for any responses :)


* - 0xBB - May 2, 2016

His approach seems quite good : http://alexstv.com/index.php/

Here is a more conventional approach http://code-phi.com/infinite-terrain-generation-in-unity-3d/

Unsure what will suits you the most.