Hi guys! I've been trying to mess around with Procedural 2D Terrain Generation using Voxels. I've followed this tutorial playlist: 2D Voxel Terrain Generation Tutorial But I've hit brickwall that I'm not being able to bring down. Not only it gets slow when destroying or creating terrain when the therrain already has many different types of squares (like grass stone and etc), but creating the colliders is even slower (I've tried using 2D Box Coliders and Polygon Colliders, both generated using the MeshFilters Mesh), even if I do it using Coroutines. Is there any good tutorial out there that you can point me to? Any tip or starting point, or anything I should be looking at before starting on this journey? I'm not even interested in Marching Squares, only in 2D Voxels. If there is any need, I'll share the code. Thank you in advance!
It's possible that tutorial doesn't make a performant implementation. You could use the profiler (Window -> Analysis -> Profiler) to investigate what is taking so much time. Alternately you could try another tutorial, but it isn't simple to see a tutorial and decide if it would be performant.
hmmm I know in the past I tried around with runtime editing of 2D TileMaps (as in place/ remove/ change a tile in my world on runtime) and that worked perfectly fine as far as I remember
I did xD The problem lies in the loops, they take too long to process data, and if I do them in coroutines, the collider takes a bit to be generated, so if I created a new block, the collider would appear after about 1 sec or so.
As always with performance the key is to do less or to do it less often. This may involve cleverly caching stuff that doesn't change, or only updating stuff that is very close to the player (or other enemies), etc.
That is something I actually thought of, of course that for now, given testing porpuses, I am inserting and removing blocks every frame. I think I'm going to have to rethink all my code, I do not believe it to be as efficient as it could/should.
Well what I was trying to say earlier, was - i might be wrong because i only skipped through those tutorial videos but - it looked like your tutorial is essentially reimplementing a new way to make tilemaps though unity already has something for tilemaps, see the https://docs.unity3d.com/Manual/class-Tilemap.html as far as I can remember its a bit awkward coding wise to change tilemaps on runtime, but it is perfectly doable and when I did it i didnt have much performance issues you might be able to do what you want using thoses instead of reimplementing a tilemap system from scratch
Yeah, my ignorance got the best of me x'D As soon as I heard about the Tilemap I tried something, which was basicaly 1000x more tiles than those tutorials and it worked with little to no impact on FPS. I think I'll stick to this one Thank you very much !!!