- Home /
How to generate an infinite level ?
This is what i want to achieve : A straight road whith a few houses on both sides. Nd i want the same level / plane to be generated in front of me when i reach the end of the road.
Something like this : https://youtu.be/xlSkYjiE-Ck
An infinite level hasn't any end
You have provided a link to a TUTORIAL explaining step by step how to do an infinite level
FAQ :
Some reasons for getting a post rejected:
You haven't provided enough context: we need more information about your problem, relevant code snippets and what you have tried already.
Argh, I accidentally published that question, sorry.
Answer by Shrikky23 · Dec 05, 2016 at 03:27 PM
I will explain you one of the concepts, You have the freedom of implementation. I did procedural generation in my capstone project and this is how we approached the problem.
Solution:
Create a long cube (road), put a box collider on it. When you reach half way through the road, generate another road and place it right next to the current cube(newcube.transform.position = new vector3( currentcube.transform.position.x, currentcube.transform.position.y,currentcube.transform.position.z + currentcube.transform.localscale.z ) .
Lets say the scale of the cube in Z is 100 units. Then you say if(player.transform.position.Z >= 50), generate a new cube. Basically you are using the scale of the cube for distance covered.
OnCollisionExit, destroy the previous cube (So you don't have 100 roads in the memory)
Extend this, work on scaling of the cube, number of cubes you want to generate in front of you etc.
You can do more fun stuff by having an array of roads(with different obstacles) and randomly place one road everytime. You can also have 3 different arrays of roads with different density of obstacles for changing the difficulty in game dynamically.
I hope this helps.
Your answer
![](https://koobas.hobune.stream/wayback/20220612102102im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Webplayer issues on a MAC - Player keeps moving 0 Answers
Is it possible to run one scene in VR and separate camera angles of that scene on another monitor? 0 Answers
Amplify Color Effect -Volume Collision Mask 0 Answers
he Mecanim Locomotion Stater Kit can no longer be downloaded from the Asset Store. 0 Answers