TerrainData class

Hi,

i would like to measure the size of the terrain i’ve created…

how do i actually use the code?

var terrainData : TerrainData;
var heightmapWidth : int;

function Update()
{
  var viewPos = camera.WorldToViewportPoint( target.position);
  
   if(viewPos.x < TerrainData.heightmapWidth)
   {
        bla bla bla...
   }
}

but there is an error :
an instance type ‘UnityEngine.TerrainData’ is requried to access non stactic member ‘heightmapWidth’

hope there is someone that can help me =)
Thank you so much =)

Watch the capitalization…your variable is called terrainData but you’re referring to TerrainData in your code, which is a different thing. Also, heightmapWidth is the width of the heightmap in samples and doesn’t have anything to do with physical size. You want to use .size for that.

–Eric

oh okie…
thankz eric =)

but still it doesnt work…
i’ve an error on the

 if (viewPos.x < terrainData.size)

error:
Operator ‘<’ cannot be used with a left hand side of type ‘float’ and a right hand side type ‘UnityEngine.Vector3’

hmm…
if i need to move the camera…
and once the camera move out of the terrain…
it will stop…

is there anyway i can code it?

sorry for noob questions… =x[/quote]

As the error says, you can’t compare a float against a Vector3. You’d want to do something like “if (viewPos.x < terrainData.size.x)”.

–Eric

Thank you so much eric…

i’ve another question…sorry…

when i do according to your code…
selet the terrain into the TerrainData using the inspector…

it pops up another error…
says: Terrain not correctly connected to a terrainData object…

can i know…how to connect it properly?