How can I iterate through a Vector3 array, and for every Vector3, check to see whether there is a neighbouring one?
So for example if my array is (0,0,0), how can I check if (1,0,0) is there?
By neighbouring, I mean if they were 1,1,1 blocks, they would be touching. So an increase in 1 co-ordinate, but not the others.
To check, I’m using this code. However, I think there is a mistake somewhere, since the if statement does not return true for blocks on there own.
function march(){
var px = false;
var nx = false;
var py = false;
var ny = false;
var pz = false;
var nz = false;
// for (var xvalue : int in xcoords) {
for(var i : Vector3 in blocks)
{
// no need to compare twice agains smaller indices, so start at i+1
for(var j : Vector3 in blocks) {
if(j.x-i.x == -1){
nx= true;
}
if(j.x-i.x == 1){
px = true;
}
if(j.y-i.y == -1){
ny = true;
}
if(j.y-i.y == 1){
nx = true;
}
if(j.z-i.z == -1){
nz = true;
}
if(j.z-i.z == 1){
pz = true;
}
if(nx == false && px == false && ny == false && py == false && nz == false && pz == false){
print ("i is " + i + "j is " + j);
}
}
}
}