Help clicking on 3d objects

absolute panda noob here

I need to receive the coordinates of a mouse click on a 3d surface. Mostly I’ve been following code from but after calling traverse(render) on my traverser object, my collisionhandlerqueue object is still empty.

I’m thinking I need to set a collision mask on the visible geometry somehow, but the line


which I thought would be the brute force solution doesn’t seem to have done anything.

Attached is my code and the OBJ model to be clicked
Hand.obj (656 KB) (4.2 KB)

Hi, welcome to the forums!

It helps to call this:


This will show visual debugging information about what collisions are happening.

This shows that the collisions are happening (in fact, since the “from” mask was already set to the default mask for visible geometry, setCollideMask wasn’t necessary); they are just not showing up in the queue.

Also, if you store a CollisionTraverser in base.cTrav, it will be automatically traversed every frame. This is probably not what you want in this case; you probably want to create your own traverser (and not store it in self.cTrav, but under a different name).

Finally, you probably want to call disableMouse() to disable ShowBase’s control over the camera. I’m not quite sure why this is important in this specific case, but it seems to solve the problem with the collisions not showing up in the queue.

Thank you! I’ll have to dig through the docs to figure out why that fixes it, but it works! :mrgreen: :mrgreen: