The question is answered, right answer was accepted
Array index is out of range.
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. http://pastebin.com/2aTsVfvQ
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
Answer by pako · Aug 30, 2015 at 08:29 PM
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.
Thank you millions kind sir! Im dumb that i didn't notice that but you saved lots of my time :) thanks again.
Follow this Question
Related Questions
Trying to get animation to work. Problem with JS. 1 Answer
Error) DataReader already active on this command 0 Answers
Base64 to texture decoding, js -> webgl 1 Answer
Setting EventTrigger in Unity with JavaScript 0 Answers
NullReferenceException: Object reference not set to an instance of an object 3 Answers