- Home /
Terrain toolkit procedural terrain texturing Help needed
Hey,
I'am trying to texture my terrain trough script in runtime. My script does find "terrain toolkit" script and apply function perlingenerator and It does generate terrain again by pressing button, thats works fine. BUT I do also want texture it too and theres problems.
Terrain Toolkit's example from documentation's example
var go : GameObject = GameObject.Find("Terrain");
var slopeStops : float[] = [20.0, 50.0];
var heightStops : float[] = [0.2, 0.4, 0.6, 0.8];
var textures : Texture2D[] = [cliffTexture, sandTexture, grassTexture, rockTexture];
go.GetComponent("TerrainToolkit").TextureTerrain(slopeStops, heightStops, textures);
My script:
var slopeStops : float[] = [20.0, 50.0];
var heightStops : float[] = [0.2, 0.4, 0.6, 0.8];
var textures : List.<Texture2D> = new List.<Texture2D>();
function OnGUI ()
{
if (GUI.Button(new Rect(0,0,100,100), "Generate!"))
{
var TerrData : GameObject;
TerrData = GameObject.Find("Terrain");
TerrData.GetComponent("TerrainToolkit").PerlinGenerator(8, 0.27, 8, 1);
TerrData.GetComponent("TerrainToolkit").TextureTerrain(slopeTops, heightStops, textures);
//this just doesn't work..
}
}
I have been trying solve this myself for couple of days and can't really figure it out.. Help please this is just frustrating me :/
Did you ever get this thing working in the end? Because I'm trying to do the same thing... If not then please could someone answer this question? I know that it's old but still! xD
Line 14: TerrData.GetComponent("TerrainToolkit").TextureTerrain(slopeTops, heightStops, textures); isn't indented with the if statement. Indent it!
Answer by lucas216erickson · Jun 28, 2016 at 06:43 AM
I realize this is a VERY old thread, but I just want to point out the problem. His variable is called "SlopeStops" as it should be, but when he goes to call the function to texture the terrain (line 13) he writes "SlopeTops." That was the problem.
Answer by Dudicus · Mar 18, 2016 at 09:31 PM
Try going to the Learn section of this website and go to Tutorials. Then go to Procedural Cave Generation and recreate it. Maybe change it slightly like making different materials or something.