Procedural City Generation
Hi everybody, I'm trying to make a procedural city for a game I'm making, but the problem is that I have no idea what method to use and how exactly how I'm going to use that method to create a few kilometer city with a good frame rate. Please help :|
Oh also I work in C# so if you want to include any code, may you please make sure its C# or else I want have a clue of what you're saying.
Right now I'm trying to make the roads out of one procedural mesh, Is this a good idea or not?
Answer by Jato · Jan 06, 2016 at 01:39 AM
@KodingKaralis If you have several structures that you would like to create but you want them randomized in position and frequency then I would suggest using [Instantiate](http://docs.unity3d.com//ScriptReference /Object.Instantiate.html) and some random variables. This is not a finished script there will probably be a few bugs but a concept like this should work
Create an empty gameobject give it this script: Say you have 3 buildings that you want generated and you have them set to with variables as 1)House 2) Hotel 3)Lodge and var spawnHouse = 10; var spawnHotel = 10; var spawnLodge = 10; var structureCount = 0; void Update () { spawnHouse = Random.Range(0,11); spawnHotel = Random.Range(0,11); spawnLodge = Random.Range(0,11); if(structureCount >=10{ if(spawnHouse == 0){ Instantiate(House, transform.position, transform.rotation) structureCount = structureCount + 1; } if(spawnHotel == 0){ Instantiate(Hotel, transform.position, transform.rotation) structureCount = structureCount + 1; } if(spawnLodge == 0){ Instantiate(Hotel, transform.position, transform.rotation) structureCount = structureCount + 1; } } and then in the void start for the script for each of the structures use Random.Range for x and z coordinants.
I like this but what I'm really need help with is the road map generation, not the buildings. Sorry about that, should've clarified :). Is there any way I could make a city map like the Subversion Game?