- Home /
Randomly Generated Terrain
How can I place objects in specific places on randomly generated terrain? Sort of like a biome.
Answer by gogu23 · Aug 14, 2013 at 10:10 PM
You can try to look in the unity script API and under INSTANTIATE http://docs.unity3d.com/Documentation/Manual/InstantiatingPrefabs.html
Becouse is sounds like you have made the random terrain and just wants the Gameobjects to be spawned if i follow you ?
Well it's more like I've generated a random terrain and now there's different areas which require different gameobjects but since these areas are completely random each time the game is ran I need to figure out a way to spawn specific gameobjects in specific locations.
Answer by robertbu · Aug 14, 2013 at 10:44 PM
If height is the only issue, you can use Terrain.SampleHeight() to place the object at the correct height. If you need both the height and the slope, you can Raycast() down on the terrain using a form of Raycast that takes a RaycastHit struct. From the struct you will get the position of the hit (point), and the slope (normal). You can use both to place and rotate your object to match the terrain.