How do I register a mouse click?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Solko

Hi, I’m new to godot.
I want to create an object that can register when it’s being clicked on. I’ve searched for how to do this but the information is confusing or outdated or both. What function do I use?

Using signals — Godot Engine (3.5) documentation in English
did you look at this

Enfyna | 2023-05-29 19:25

:bust_in_silhouette: Reply From: friskybear

One simple workaround that I’ve used is adding a button node to whatever node I want to be clickable.

I then set the transparency of the button to zero so it’s not visible. (CanvasItem Modulate set A to 0) Or you can toggle the “show behind parent” property so it’s behind the parent node.

Then connect the “pressed” signal from the button to your script, and you have a clickable node! Also make sure to size the button correctly

Thanks! You explained it in a way that I could understand :slight_smile:

Solko | 2023-05-30 16:59