Ok i assigned the script to the terrain and i get a error that says:
“IndexOutOfRangeException: Array index is out of range.
AssignSplatMap.Start () (at Assets/Terrain/Ground/Scripts/AssignSplatMap.cs:51)”
I have done everything right i think but it is just not working.
Here is the full code.
I have three textures assigned to the terrain too.
Terrain size is 10000 x 10000
If you know what wrong then please share!
Thanks,
-Klaus
pako
2
In line 35 of your code, you set the size of the splatWeights array to be equal to alphamapLayers:
float[] splatWeights = new float[terrainData.alphamapLayers];
You don’t post enough info to show what could be the possible values of alphamapLayers, but it seems that this value is smaller or equal to 3, and this is why you are getting the Array index is out of range error in line 51 of the script, which is:
splatWeights[3] = height * Mathf.Clamp01(normal.z);
In this line of code you are setting the value of the 4th element of the array, which doesn’t exist and you are getting the error. So, you must make sure that terrainData.alphamapLayers is always at least 4, in order to get rid of the error.