Is it possible to plant some objects in terrain system that have equal distances from each other?


I have a place with about two thousands of pillars with equal distances from each other, and want to do it with terrain system. Is it possible to tell unity to plant each pillar at a specific location, for example, each 4 meters on pillar.

You can do this with scripting.

If your slopes aren't steep, and the distances don't need to be exact, you can just place your objects in a x,y grid ABOVE the terrain, and for each object do a raycast straight down to see where each objects hits the terrain, and place it there.

If your distances DO have to be exact, I would suggest this:

  1. Place your first object using the above method.
  2. Assuming you want 1 meter between each cylinder, you will have a loop in your script that starts 1 meter directly above your 1st cylinder, and performs incremental raycaysts in a semicircle until it ends up directly beneath your 1st cylinder. If your next cylinder should be to the "right" of your 1st cylinder, the semicircle will be the right half of a circle, centered at your original cycinder, extending to the right. I hope this makes sense.

This should give your the exact location of the terrain 1 meter "to the right" from your original cylinder.

Note, the increments you use as you go along the cylinder will determine your accuracy. Rays being cast .1 unit long as you go around the circle will be much more accurate than .25 units, but will be slower of course. It all depends on how accurate you want to be.

I hope that gets you started, and is helpful.

Maybe someone with access to the code right now could write a quick "Find terrain hits in a circle" function, that checks in a circle of a given radius, along a given axis, given the coordinates and step amount.

unfortunately this process is unable to be scripted and what you want is not currently possible