- Home /
Question by
DeadKenny · Nov 28, 2014 at 12:38 PM ·
textureterrainarrayproceduralterraintoolkit
Terrain Toolkit and Texturing via Code HELP!
I am having trouble getting the TerrainToolkit.TextureTerrain to work... It give the error message that the heightStops array is out of range. Or at least I think its the height stops.
What am I doing wrong?
public Texture2D[] desertTextures;
//
void Start () {
//Set textures....
float[] sStops = new float[2];
float[] hStops = new float[4];
Texture2D[]tTexs = new Texture2D[1];
sStops[0] = 30f;
sStops[1] = 70f;
hStops[1] = Random.Range(0.05f,0.18f);
hStops[2] = Random.Range(0.19f,0.28f);
hStops[3] = Random.Range(0.5f,0.48f);
hStops[4] = Random.Range(0.7f,0.80f);
this.GetComponent<TerrainToolkit>().TextureTerrain(sStops, hStops, desertTextures);
}
}
Comment
Best Answer
Answer by tanoshimi · Nov 28, 2014 at 01:23 PM
Array accesors are zero-based. So if hStops is declared as float[] hStops = new float[4]
, it has four elements: hStops[0], hStops[1], hStops[2], and hStops[3].
You're trying to set hStops[1] - hStops[4].
Oh god lol. Thanks man.
It blurred my terrain in the editor though. However I think everything is working. Thanks.