- Home /
mass place rocks
How would I start with mass placing rocks like shown in the above picture. I have a very large terrain (20000x20000) and i would like to have rocks placed randomly around without having to place them by hand.
The problem is (like you see in the picture above) the rocks are oriented with the terrain to give it a random look. If your terrain was flat, you could write a script that would just randomly instantiate rock object: Instantiate(rock, new Vector3(Random.Range(0, 2000), 0, Random.Range(0, 2000)), Quaternion.Identity);
@amphoterik couldn't he just use a normal to make the rocks align with the terrain? Perhaps with some $$anonymous$$or randomness factor.
@Em3rgency absolutely. I guess my point was that the "natural" effect is hard to achieve through scripting. When someone shows an imagine of a hand sculpted map and asks "how do i do this with scripting", the real answer is that you cannot. I suppose I am just not speaking clearly this morning :)
@amphoterik how would I align randomly instantiated objects with the terrain? would i raycast from the object or would I just use terrain.getheights to set the correct position and rotation?
I don't have a lot of experience with Terrains, but I'd probably use TerrainData.GetHeight() along with TerrainData.GetInterpolatedNormal(). I'd want the normal so that I could align the rock with the surface. Plus I'd likely avoid putting rocks on steep hillsides.