I’m wondering what would be the best way to place a bunch of trees over a large terrain. I have three different types of trees and I’d like them to be scattered around the map. Also I do have size variations of these trees. Is there any way to take all of these objects and duplicate them and scatter them around in random positions?
1.- Using trees as objects
2.- Using trees as terrain items
In both solutions (or at least in solution 2) you must know how terrain works. Terrain is a 2D matrix where every “cell” or point of the terrain is an element on that matrix. Every element has info about height of that point, texture, terrain items as grass or trees…
So in the first solution you can do that in 2 ways:
a) locate randomly a raycast emitter above the terrain, raycast in y axis down and place the tree object where the raycast colides with the terrain.
b) find randomly a 2D point of the terrain (x, z), get its height, convert it to global position (y) and place the tree object.
And in the second solution is the previous b) solution but instead of placing a gameobject you add a terrain tree to that matrix point, or terrain coordinate