- Home /
[C#] 2D infinite Terrain Generation with prefabs?! -> lag
Hi, i'm currently working on a topdown game. I already have a infinite terrain generator (works with SimplexNoise) and a chunk system (a chunks loads, if needed and will be destroyed if its too far away; each chunk has 16 tiles) It looks like this:
1) If the player moves and generates new terrain it lags. Thats because each tile is a prefab (a quad) that will be colored (remember? a chunk consist out of 16 prefabs) -> lag
2) Below you find a version where each chunk is a quad and i modify only the pixels on the quad instead of creating tiles:
http://www.codebukkit.de/michidk/Web.html
no lag
3) then i tried this ObjectPool: http://unitypatterns.com/new-tool-objectpool/ the result is the same as 1) -> lag
4) i tried to use coroutines, but then it tooks too long to load the chunks:
and even there: -> lag (not much as above)
i need prefabs, because i need colliders (you can't swim and climb up mountains)
i need a lot of chunks because it takes so long to load a chunk, and the player is very fast
has someone an idea, how to slove this problem?