Search Unity

Programmatic Terrain Data Incorrect Values

Discussion in 'Scripting' started by Jagwire, Jul 9, 2015.

  1. Jagwire

    Jagwire

    Joined:
    Dec 5, 2013
    Posts:
    59
    I'm instantiating a Terrain object with Terrain.CreateTerrainGameObject(); quite literally:

    Code (csharp):
    1.  
    2. TerrainData td = new TerrainData();
    3. td.size = new Vector3(129, 100, 129);
    4. td.heightmapResolution = 129;
    5. GameObject t = TerrainCreateTerrainGameObject(td);
    6.  
    And in the inspector the Terrain Width and Terrain Height both display: 516 (129*4).

    Why is are these values getting multiplied by 4? Furthermore, how do I set them such that they don't get changed?
     
  2. Jagwire

    Jagwire

    Joined:
    Dec 5, 2013
    Posts:
    59
    *sigh*, As it turns out, if I set the resolution first, and THEN the size, the size will stick as desired. I sure wish this had been documented somewhere o_O