Search Unity

set terrain size via script

Discussion in 'Scripting' started by Deleted User, Nov 19, 2012.

  1. Deleted User

    Deleted User

    Guest

    Hey community

    I have a problem with setting terrain size via script.
    example:
    Code (csharp):
    1.  
    2.  
    3. int width   = 1000;
    4. int lenght  = 1000;
    5. int height  = 600;
    6.  
    7. TerrainData.size = new Vector3(width, height, lenght);
    8.  
    9.  
    this should give me a terrain with the given values... but when I select the created terrain in my scene and go to terrain/set Resolution it shows that my terrain is 600 in height, which is correct, 16000 in width/lenght !?

    Anybody knows whats going wrong?
     
  2. Deleted User

    Deleted User

    Guest

    bump
    anyone? :(
     
  3. Dunlain

    Dunlain

    Joined:
    Feb 20, 2013
    Posts:
    2
    I have a similar issue, did you ever figure out the problem/solution? My terrain always is flat, but when I modify it with the editor it does what it's supposed to...
     
  4. Deleted User

    Deleted User

    Guest

    I scratched that project but I have it still on my hard drive...
    It seems that dividing length and width by 16 gets the right results. Don´t ask me why ;)

    Code (csharp):
    1.  
    2. int width   = 1000;
    3. int lenght  = 1000;
    4. int height  = 600;
    5.  
    6.  TerrainData.size = new Vector3(width / 16f, height, lenght / 16f);