Why my area2d wont work on the main scene

im trying to create a turn-based battle game and i created a SelectArea (it extends from Area2D) to capture the mouse entering and leaving the select area i defined for the entity, but when i run in the main scene it doesnt work, the _on_mouse_hover doesnt run it seems, but on the entity scene it works, i cant see where how to fix it so hopefully someone has the answer
here’s the code for the SelectArea just in case:

class_name SelectArea
extends Area2D

signal clicked

@export var entity: Entity

var mouse_hovering: bool = false

func _init() → void:
	mouse_entered.connect(_on_mouse_hover.bind(true))
	mouse_exited.connect(_on_mouse_hover.bind(false))

func _on_mouse_hover(hovered: bool) → void:
	mouse_hovering = hovered

func _input(event: InputEvent) → void:
	if event is InputEventMouseButton:
		var left_mouse_pressed: bool = (
			event.pressed
			and event.button_mask & MOUSE_BUTTON_LEFT
		)

		if mouse_hovering and left_mouse_pressed:
			clicked.emit()
			print(entity.name, " was clicked")

(and i did set one collision_layer to be active, and input_pickable is true, so it should be firing the mouse_entered and mouse_exited)

How I would troubleshoot this with the information provided.

  1. Add some print output to _on_mouse_hover.
  2. Create a new scene.
  3. Add the SelectArea to it.
  4. Verify it works as expected.
  5. Copy and paste one of the nodes from the main scene into the new scene.
  6. Test the SelectArea works as expected. If it does, repeat steps 5 & 6. If it doesn’t, you’ve probably identified the node that causes the issue.

Better habit to use _ready() for this instead of _init(), I don’t think there will be any problems this time but _init causes a lot of issues.


This tab in the Debugger can tell you if your mouse input is being consumed by something before the area can detect it.

so i came back with this:

i did what you suggested, i created a new scene and began testing, the SelectArea works fine on the entity scene and the test scene, it just the main scene that it does not work, so probably the main scene is main problem here

And the results of steps 5 & 6?

i discovered now:

i added a ColorRect to serve as a background, and he was consuming the input before the SelectArea fired the mouse_entered and the mouse_exited, so i set the ColorRect mouse_filter to Ignore, and its working now