I try to use Physics.CheckSphere to check if a coordonate is empty. I use three for loop to cycle threw a 2 x Y x 2 chunk. The problem is that it return true if the corner is touching the coordonate
and its actually not even touching it, since I use a 0.5 sphere radius: if(Physics.CheckSphere(new Vector3(x,y,z), 0.5f) == false)...
(by the way the white cubes you can see on the picture is only to visualize where it detected empty space, they dont have any collider enabled)
and the chunks have a mesh collider, so why is it returning true when its no even touching it ?
if(Input.GetKeyDown("i")) {
for(int y = 0; y <= amp + 3; y++)
{
for(int x = 0; x <= chunkSize - 1; x++)
{
for(int z = 0; z <= chunkSize - 1; z++)
{
if(Physics.CheckSphere(new Vector3(Mathf.Round(x),Mathf.Round(y),Mathf.Round(z)),0.5f) == false)
{
Instantiate(grass,new Vector3(x,y,z), Quaternion.identity);
dontPlaceHere.Add(new Vector3(x,y,z));
}
}
}
}
}