Hi there,

I have this structure:

Scene: Brick.tscn - Script: Brick.gd Brick: StaticBody2D func _input(event): if (event is InputEventMouseButton) && (event.is_pressed()): print(name) #self.queue_free()

Scene: Level.tscn - Script: - Rows: Node2D -- Row_1: Node2D ---- Brick1 (instance of Brick.tscn) ---- Brick2 (instance of Brick.tscn) -- Row_2: Node2D ---- Brick3 (instance of Brick.tscn) ---- Brick4 (instance of Brick.tscn)

What happens: I have four bricks in two rows. I click on one Brick and get back the name of all instanced bricks.

What I expect: I click on a brick and get back the name of clicked one. Later i want to free the clicked brick.

I do not understand why i get back all bricks. Any Idea on what I'm doing wrong here?

Thanks Antonio

Uses: Godot 3.0.6 / GDScript

Seems like your bricks just print their names whenever the mouse is pressed, disregarding whether the cursor is pointing at the brick or not. You need to check for the mouse pointer position as well, not only for button press.

5 days later

Hi again,

i finally found out what the problem was. I think for a newbie this is a big obstacle, and it gave me headache for at least two weeks until i found a post with a similar question on reddit.

Around the nodes i posted above there are some other nodes in higher hierarchy of control type. Controls have a category mouse and a property Filter (docs: mouse_filter). Don't know if others have that also. The default value is set to Stop (others values: Pass and Ignore).

Set to Stop prevents the mouse event being passed to other nodes.

I had to check all of my nodes and set the Filter property to, in my case Ignore, after that my mouse click and the correct object where recognized.

Hopefully this info helps others.

regards Antonio

4 years later