How to detect when player has clicked on a certain node without using a button

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

In a (2D, if it helps) game I’m making, I want the player to be able to pick up items by clicking on them. Is there a way to detect the player clicking on a node without using a button node?

:bust_in_silhouette: Reply From: TheIronGod

You can use any node with a collision shape such as an Area2D or RigidBody2D. They have on_mouse_entered and on_mouse_exited signals you can use to know when the mouse is on the item, then just write the code for your controls incorporating that information.

1 Like