Why is this not working?
This is basically trying to get the heights of a certain point in the terrain, but that last part (“Get heights”) is causing a cannot convert to int issue.
Full error " error CS1503: Argument #1' cannot convert
float’ expression to type `int’"
Its basically the positions bPosX1 and bPosY1… it simply wont work if I put them into the get heights. Without the getheights code everything works fine. So the convertion part of bpoX01 and bposY01 seems to be fine.
float bposX01 = bZone1.transform.position.x;
float bposZ01 = bZone1.transform.position.z;
float bposY01 = GameObject.Find("Terrain 0 3").GetComponent<Terrain>().SampleHeight(new Vector3(bposX01, 0, bposZ01));
Vector3 nPos = (transform.position - terrainObject.gameObject.transform.position);
Vector3 crd;
crd.x = nPos.x / ter.terrainData.size.x;
crd.y = nPos.y / ter.terrainData.size.y;
crd.z = nPos.z / ter.terrainData.size.z;
bposX01 = (int) (crd.x * terrain.terrainData.heightmapWidth);
bposY01 = (int) (crd.z * terrain.terrainData.heightmapHeight);
//Offset...
int ost = Inst1._size / 2;
//Get heights.
float[,] hPoints = ter.terrainData.GetHeights(bposX01-ost, bposY01-ost, size, size);
Please help… thanks.