How to get 3D coordinates from mouse

Oh, if you just want a point on the plane, then this is quite easy with Panda–the “Plane” class provides a neat convenience method for determining the intersection of the plane with a line. See this post for more:

The code that you have is more generalised: it should pick up any collision-object that you might have in the scene. (Presuming that you don’t use bitmasks or other tricks to prevent this.)

If that’s what you want, then you might look at the manual entry for CollisionHandlerQueue for a partial example and some of the methods involved in getting the first hit of the ray.

As a side-note, let me point out that you don’t have to construct your traverser, handler, ray, etc. every time the task is run–it would be a little more efficient to do so only once, before the task is used, I imagine!

1 Like