I am doing a terarria like game and to make the generation happen I use 2 for loops.
One for x and one y generation.
However, every time it generates there is a clear lag.
In games like minecraft and terraria they have a loading bar that causes almost no lag…
Well, strictly speaking, you’re looking for asynchronous creation/loading. Stuff happens on another thread while the UI (like the loading bar) updates on the main thread.
It’s a very very advanced topic, so for now, I wouldn’t recommend looking into that until you’re more familiar and comfortable with the core concepts of Unity and programming in general.
What you could do is break up your loops into coroutines so that you only generate one row per frame, and update the loading bar on each iteration.