[New] Trouble when check the picking results & [SOLVED] Trouble in putting many models(will be operated) together

For using Lemur someday the best way to get started is to read the “Getting started” documentation which will help you figure out how to get started:

For future reference, here is how you do code blocks:

public int[] getGrid() {
    CollisionResults results = new CollisionResults();
    Ray ray = new Ray(cam.getLocation(), cam.getDirection());
    shootables.collideWith(ray, results);
    if (results.size() > 0) {
        int [] cor=new int[2];
        CollisionResult closest = results.getClosestCollision();
        for (Spatial e:shootables.getChildren()) {
            if (closest.getGeometry().equals(e)) {
                loop:
                for (int i =0;i< mineField.getRow();i++) {
                    for (int j=0;j< mineField.getCol();j++) {
                        if (e.equals(temp[i][j])) {
                            cor[0]=i;
                            cor[1]=j;
                            break loop;
                        }
                    }
                }
            }
        }
        return cor;
    }  else {
        return null;
    }
}

Probably the geometry you get is the child of the shootable… so when you fail to find it in the shootables children then you should check its parent.

…or even better, just getParent() until you find the shootables and then use the previous one.

Spatial hit = null;
while( hit.getParent() != shootables ) {
   hit = hit.getParent();
}

…which is why I suggested using getParent() before.

In general, it seems like you might be pretty new to Java and your code seems to be doing everything the very hardest way possible. In the future, you may want to focus more on learning coding basics before attempting a 3D game.

As practical advice, you could remove a lot of code there by storing the row and column right on the shootable children when you create them using setUserData().

1 Like