Hi folks! 
I am a student, and brand new to Unity, but I am really liking what it offers so far.
My group and I are attempting to develop a 3D skiing game in Unity for our project, and I am looking into writing a C# script that will randomly place a tree prefab (with collider) over the surface of the mountain terrain I have created.
Any thoughts out there about how to approach this?
I’m thinking that I need to instantiate the tree object in a loop, restricting values so that they don’t overlap, but how would I go about ensuring that the tree’s y value puts them on the terrain surface?
Would it be a better idea to use several heightmaps or treemaps to predefine where the trees will go and selecting one of them at random upon start up?
Any resources or ideas would be greatly appreciated! Thanks!
Assuming this is done on a terrain, click on Terrain (at the top of the screen), then click on mass place trees. Select how many you want to place and you will have a load of trees on your terrain. On setting, check create tree colliders, and you’re done!
Raycast to find terrain height at the location the tree will be placed (If you are a stupid noob like me). Or if you are smart use Terrain.sampleHeight as cat_ninja suggests.
I still don’t really know much about the terrain map system but I’ll be looking into it sooner than later, I would be interested in learning how to modify the map itself and then scripting based on that if anyone has any thoughts.
I am totally new to Unity but a tips when it comes to trees, if you create them yourself, always make sure that the ppivot point is a little up the trunk so the bottom of the tree is not exactly at the 0 point position. It will look strange when the tree is on a slope etc
Well for something like this there’s Terrain.sampleHeight i think, it’s gets the height of the terrain at that point, so you can generate a random Vector 3 then change the y value to the sample height, and Unity has a generate trees tool in the Terrain options, but if it’s a skiing game that needs to geneate trees as your moving then it’;s good to have a script