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)
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
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