I've written a custom Node3D which I'd like to act like a button. I want to detect when the user clicks on it with the mouse so I can then emit a signal that will be used by another part of the program. I'm having trouble finding a straight forward way to doing this. Right now I'm overriding _input() to check for mouse clicks and then doing a raycast from the camera to see if it intersects with my button's Area3D. This works, but seems to me to be very inefficient. Is there a better way to do this?
How to detect user clicking on an Area3D?
Area3D has an input_event signal. No need for manual raycasts. Just connect a function to this signal.
- Edited
I've tried that, but it only reports a mouse motion event when the mouse first first hovers over the region. I get no events from mouse button clicks or subsequent mouse motion events.