3D Mouse Picking Test demo functionality in a new project

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By KJB
:warning: Old Version Published before Godot 3 was released.

I’m new to Godot, and using 2.1.1 on win7x64.

I’m trying to transfer the functionality of mousepick.gd from the demo to another project. In the other project, I added a RigidBody with Mesh and CollisionShape children, named the same way as in the demo so that the get_node call should work. AFAICT the properties and settings of the RigidBodys and their children are identical in both projects, and the RigidBody is the one with the script attached.

Yet, aiming the mouse at it (or clicking) when you run the project doesn’t affect the object like it does in the Mouse Picking Test demo. (Also adding a print statement doesn’t show anything printing. If I add it to the same place in the demo, it prints.)

One difference between the projects is that the new project has a root node that’s just a plain Node, then under that is a 2d canvas node for gui and a 3d spatial node for the scene. Within the spatial node is another spatial node, and that one actually contains the RigidBody objects. Another difference is that moving the mouse moves the camera–but the mouse cursor is still in the centre of the window, so I figure that pointing the centre of the window at an object ought to fire the attached mouse events, but it doesn’t.

I can successfully add a fifth clickable object to the demo, so I’m not understanding what I’m missing adding it to another project. I’ve exported both the mesh and the collideable shape and imported them into the other project.

Any ideas where to start in debugging this?

update
It must have something to do with the moveable camera, because if I add that part of it to the demo, the clickability goes away just like in the other project. But I’m not sure the cause of that…

update 2…SO CLOSE!
Some progress, I now have the demo working clickably with a moveable camera, so long as I get rid of this code:

func _enter_tree():
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED);

The only thing is, getting rid of this code in the other project does not fix the problem.

Well, that, and the fact that then the mouse cursor moves around on top of the window, so I can’t just put a crosshair in the centre and be done with it.

update 3

MOUSE_MODE_HIDDEN isn’t it either: clickability works, but the mouse can then escape the window. Also the clickability is hard to actually use because it depends on overlap with the invisible cursor, rather than the centre of the window…