- Home /
Question by
kampiria · Feb 06, 2017 at 08:24 AM ·
terraindatasetheights
terraindata.setheight as a brush for runtime terrain editing
my apologies if this has been awnsered before but i've spend 2 days searching with no results but i have made( i'll be honest and say that i copied it) a terrain editor that can be used during runtime by the player however whenever i use it it only raises the smallest of points since it works with a raycast shooting from my mouse
so my question is how do i make it raise a larger area of effect
void raiseterrain(Vector3 point){
int mousex = (int)((point.x / terndta.size.x)*heightmapwidth);
int mousez = (int)((point.z / terndta.size.z)*heightmapheight);
float[,] modifyheights = new float[1,1];
float y = heights[mousex, mousez];
y += strength * Time.deltaTime;
if (y > terndta.size.y) {
y = terndta.size.y;
}
modifyheights[0,0] = y;
heights[mousex,mousez] =y;
terndta.SetHeights(mousex, mousez, modifyheights); //<---- this needs to become an area instead of a singular point
}
once again my apologies if it has been asked before but i just cant seem to figure this out
Comment
Best Answer
Answer by OracleOfNothing · Apr 21, 2019 at 10:40 PM
https://answers.unity.com/questions/714192/terrain-editor-brush.html This answer has a script which does just that.