2D Infinite Runner: how to manage the generation of dynamic terrain?

I’m creating a infinite runner game with Unity3d, i’ve been using math to generate the terrain by calculating the size/pos of the terrain and place the new one next to it, and it’s working correctly, but i think it’s a overkill, so the question is, Is there a better way(performance) to generate terrain/floor in 2d scrolling infinite runners?

I also tried this method which consist of using empty gameobject, and when you hit them it create the terrain it was okay, but then problem started when i started using different terrain generation.

Terrain generation in an infinite runner is typically done with a chunk based loading system. Each chunk contains a pre-generated or procedurally generated terrain mesh. We use meshes to reduce the overall game object count. Chunks would be used in a pooling system as well, so you aren’t always generating new game objects at runtime. So as you run along the terrain, a new chunk is activated from the pool and setup before that section of terrain would come on screen. Likewise, when a chunk has left screen and is no longer visible it would deactivate and return to the pool. What you need to decide is in what way your world is displayed…whether it be by tiles or other mesh techniques.

1 Like

Thanks, it was the solution, thanks for your time. :slight_smile: