Modifying terrain texture not updating

Hey all,

I have been looking over unity aswers and the forums for the last hour and made some headway into modifying terrain textures at runtime, but at the moment I’m not getting any update.
Previously, my entire texture map was turning black, but I changed to a system that only updates certain elements on the terrain, however it is not drawing.

Anyway, here is my code:

`Public class TerrainPainter : MonoBehaviour {

TerrainData terrainData;

float[, ,] splatmapData;

public GameObject phoenix;

// Use this for initialization
void Start () {

	terrainData = Terrain.activeTerrain.terrainData;
}

// Update is called once per frame
void Update () {

}

void FixedUpdate() {

	splatmapData = terrainData.GetAlphamaps(0,0,terrainData.alphamapWidth, terrainData.alphamapHeight); 
		//new float[terrainData.alphamapWidth, terrainData.alphamapHeight, terrainData.alphamapLayers];
	
	float[, ,] element = new float[1,1,3];
	
	Vector3 pos = phoenix.transform.position;
	
	element[0,0,0] = 1f;
	element[0,0,1] = 0f;
	element[0,0,2] = 0f;
	
	int y = (int)(pos.z - Terrain.activeTerrain.GetPosition().z / (terrainData.size.z / terrainData.alphamapHeight));
	int x = (int)(pos.x - Terrain.activeTerrain.GetPosition().x / (terrainData.size.x / terrainData.alphamapWidth));
	
	Debug.Log(x +"," +y);
	
	splatmapData[x,y,0] = element[0,0,0];
	splatmapData[x,y,1] = element[0,0,1];
	splatmapData[x,y,2] = element[0,0,2];
	
	terrainData.SetAlphamaps(0, 0, element);
}

}`

Any help would be appreciated guys :smiley: Also; it’s running slow as hell at the moment :frowning:
Could it be that I havent set up something in the editor properly?

I know this is from 2 years ago but better late then never.

splatmapData[x,y,0] = element[0,0,0];
splatmapData[x,y,1] = element[0,0,1];
splatmapData[x,y,2] = element[0,0,2];
 
terrainData.SetAlphamaps(0, 0, element);

should be

 terrainData.SetAlphamaps(0, 0, splatmapData);