- Home /
Why cant I do this? Incorrect number of values(terrain and array related).
Ok so I am trying to paint my terrain procedurally but it only allows me to use 4 terrain textures.
I cant increase it at all, it says "incorrect number of values", whats happening? I tried adding more more heightstops but it didn't work either. I tried many things, all failed.
Here is the code:
float[] sStops = new float[2];
float[] hStops = new float[4]; //This has to be same number as terrain textures.
sStops[0] = 0.1f;
sStops[1] = 25.0f;
hStops[0] = Random.Range(0.01f,0.015f);
hStops[1] = Random.Range(0.08f,0.58f);
hStops[2] = Random.Range(0.37f,0.98f);
hStops[3] = Random.Range(0.71f,1.0f);
this.gameObject.GetComponent<TerrainToolkit>().TextureTerrain(sStops, hStops, dTextures01);
So recap: This code above paints the terrain with the 4 textures in dtextures01 but I cant increase it to more than 4? How could I do that?
Thanks.
This is not a limitation of Unity's terrain, but of whatever your "TerrainToolkit" component is. You'll have to look through that script and debug the error there.
@tanoshimi is right, this isn't core Unity but if it helps any this is the code:
Look at line 2453.
Ok thanks dudes, that helps a lot. Hasn't solved it but it helps.
It seems you can add 6 but then everything becomes incredibly bright... not even sure its working to be honest.
6 textures and 8 heightstops because 8/2 = 4+2 as seen in lines near 2453.
Eh, is nobody that knows about this?
Answer by Mmmpies · Dec 25, 2014 at 10:00 PM
Just watched an old tutorial and it says that you can add up to 6 but it also adds them in the inspector not in code. No idea if it helps but this is the tutorial.
[Tutorial][1]
That's for textures but I'm assuming you need the textures in order to set at which height it applies those textures. [1]: https://www.youtube.com/watch?v=YnO9RtarzHE
Thanks will look at it. I need to sleep now, I'm brain dead atm.
Doesn't really help, I tried using 6 only and still same error. Incorrect number of values for height stops. Even if I increase heightstops to 6.
I tried using a second pass with another 4, but I don't think its working. 99% sure.
I hope someone can help.