I am having trouble picking!

i am trying to use picking in my game but i never get any pickresults, im very noob, so don't assume anything with me :slight_smile:

here is the code i have for a MouselListener attached to MouseInput.get()

      MouseInput.get().addListener( new MouseInputListener(){

         public void onButton(int button, boolean pressed, int x, int y) {
            if (pressed){
               BoundingPickResults pr = new BoundingPickResults();
               Vector3f worldCoords = GameWorld.getDisplay().getWorldCoordinates(new Vector2f(x,y), 0);
               Ray mouseray = new Ray(cam.getLocation(), worldCoords.subtractLocal(cam.getLocation()) );
               System.out.println(GameWorld.getNode().getChild(1).getName() );
               GameWorld.getNode().findPick(mouseray, pr);
               for (int i = 0; i < pr.getNumber(); i++) {
                   pr.getPickData(i).getTargetMesh().setRandomColors();
               }
               System.out.println("("+x+","+y+")");
            }
         }
         public void onWheel(int wheelDelta, int x, int y) {}
         public void onMove(int xDelta, int yDelta, int newX, int newY) {}
      });



When ever i click i do get the x and y coordinates from the system.out
GameWorld.getNode() returns the main node that my game uses. It contains the terrain and another node, that has a Box in it. But no matter where i click i get no results.

Have a look at HelloMousePick