The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

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...

in Engine by (17 points)
edited by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.