Picking problems

      self.pickerRay.setOrigin(camera.getPos())
      self.pickerRay.setDirection(Vec3(targetmdl.getPos() - camera.getPos())) 

If your pickerRay is parented to the camera, then it already inherits the camera’s transform. This means that (0, 0, 0) in the picker ray’s space is the same point that camera.getPos() is in world space. It follows that if you set your pickerRay to camera.getPos(), you are actually putting it at camera.getPos() + camera.getPos() in world space.

One easy solution is to parent the pickerRay to render, instead of to the camera. If all of your nodes, including the camera and targetmdl, are parented to render, then the logic above should work. This is the flat hierarchy preferred by many newcomers to Panda. It works fine, and it’s simple and easy to understand: you don’t have to think about coordinate spaces, and you can compute the delta between objects with subtraction, e.g. (targetmdl.getPos() - camera.getPos()).

If you wanted to do it the Panda way, though, taking advantage of the scene graph, you might do something like this instead:

      self.pickerRay.setOrigin(0, 0, 0)
      self.pickerRay.setDirection(Vec3(targetmdl.getPos(camera))) 

David