- Home /
Question by
Uriel_96 · Mar 03, 2011 at 11:53 PM ·
javascriptgridconnectionalgorithm
Find connections dont working
OK, I am trying to get connections(up, down, left, right) of the mesh and some knows at the final of the row (at the right) it cant say that the right one is a connection because it would be at the first one of the next row and backwards. So this works fine but when I set the final at the beginning of a row the variable p the values are not completely filled, this means some have a value 0. If someone want to try it an look what I am talking
function Start(){
p[finish] = 1;
nodevalue[finish] = true;
}
function Update(){
var mesh1 : Mesh = GetComponent(MeshFilter).mesh;
var nodes : Vector3[] = mesh1.vertices;
for(actualnum = 0;actualnum<nodes.length; actualnum++){
if(p[actualnum]==setvalue){
if(actualnum-subsize < p.length && actualnum-subsize>= 0){
if(nodevalue[actualnum-subsize]==false){
p[actualnum-subsize] = setvalue+1;
nodevalue[actualnum-subsize] = true;
}
}
if(actualnum+subsize < p.length && actualnum+subsize >= 0){
if(nodevalue[actualnum+subsize]==false){
p[actualnum+subsize] = setvalue+1;
nodevalue[actualnum+subsize] = true;
}
}
if(actualnum-1 < p.length && actualnum-1>= 0){
if(nodevalue[actualnum-1]==false){
if (actualnum % subsize != 0) {
p[actualnum-1] = setvalue+1;
nodevalue[actualnum-1] = true;
}
}
}
if(actualnum+1 < p.length && actualnum+1>= 0){
if(nodevalue[actualnum+1]==false){
if (actualnum % subsize-1 != 0) {
p[actualnum+1] = setvalue+1;
nodevalue[actualnum+1] = true;
}
}
}
}
}
if(actualnum >= nodes.length){
actualnum = 0;
setvalue++;
}
}
Comment
Your answer
Follow this Question
Related Questions
Get connected vertices 0 Answers
2 Triggers, 2 scripts, need help communicating the two. 1 Answer
How to have Mobile Input for a desktop game in Unity 1 Answer
just one connection 0 Answers
Javascript for simple grid puzzle? 1 Answer