- Home /
Spawning villages on random gen Terrain
Hi have randome gen terrain and am wanting to randomly generate villages throught out it i have random gen trees right now but if i do it the same way for villages as trees the spawn up in the air and are all random.
You can use raycasting to and shoot it downwards to check for ground. Then spawn your things there (assu$$anonymous$$g that your problem is spawning objects in the air).
Ive never really messed with raycasting so i just attach the script to t he prefabs of the building and that should work?
Answer by sdsanft · Dec 24, 2014 at 07:20 AM
Why don't you try using Object.Instantiate. For the first parameter, create a public variable for your village and in Unity set it to your village prefab. For the second parameter, create a new Vector3 with random values for your X & Z values and a set Y value. For your third and final parameter, enter in the value of Quaternion.identity. To do this procedurally you could create a function CreateVillage in your GameController script that uses Object.Instantiate to create your villages and then you can call CreateVillage whenever you need to create a new village.
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
Unity 5 - random tree rotation doesn't work 1 Answer
Is Terrain Glitched???? 0 Answers
My characters can't sto falling terrain 1 Answer
Terrain Texture Glitch? 1 Answer