TerrainHeight help

Hi

I need to set my terrain to certain heights at certain points based on geometry.

My setup is I have my terrain. I also have a number of buildings. As a reference, I have some planes that represent the bases of these buildings. What I want to do is run a script on this base geometry object that will level out the terrain to the height of the geometry, but not touch areas where the geometry isn’t.

All this has to happen in the editor ideally. Can any one advise?

Is this an example of what you’re trying to achieve?

Yes that’s pretty much the type of thing

Well, all you have to do is select your terrain and change the height settings under “Paint Height” in the Inspector.

I was wondering if anyone knew of a way I could automate the process via a script. I have a lot to go through you see with an extreme difference in heights and sizes. painting it by hand will become very time consuming.

OK, I’ve had a thought. I could use a ray, top to bottom. So, how could I use a script to convert world x and z position data and set the returned height ( y ) to the terrain?

Ok, I’ve come up with this. Please check it out and let me know if there’s any way I can perfect it. It adds it as a menu item

http://valrik.co.uk/LevelTerrain.rar

My script above seems to offset the levelling a little. I’ve tried using it by setting the terrain size to the terrain resolution. This does give better results but it still seems a little offset