On_mouse_entered/exited doesn't work on instanced object

Godot Version

Godot 4.2.1


I’m working on a little project of mine and a few days ago i switched to a newer version of Godot. Now the _on_mouse_entered() and _on_mouse_exited() functions only trigger once on the first instancing of my node and then never again. It’s supposed to send true and false to the console.

The node is a CharacterBody2D here is the node tree for it:
Can’t post more than one embed due to being a new user so here is the Node tree in text:

  • CharacterBody2D (has script)
    • CollisionShape2D
    • AnimatedSprite2D

Signals are connected and Input Pickable is on
I can’t figure out what could be causing this and it used to work.

Here is the script of the object that supposed to detect the interaction(My code is a mess sorry):

extends Node2D

var fishpreset = preload("res://nodes/Fish.tscn")
var inside;

func _on_mouse_entered():
    inside = true;

func _on_mouse_exited():
    inside = false;

func _process(delta):
    if inside == true and Input.is_action_just_released("left_click") and 
    get_tree().get_root().get_node("Main/UnderWater").visible == true:
	    var fish = fishpreset.instantiate()

“get_tree().get_root().get_node(“Main/UnderWater”).visible == true” part is there because in my Main node i hide one Node and show the other and have to check which node is visible so actions with the same keybind don’t trigger on both nodes

and i suspect it would also be good to send the node where it’s instanced:
In the UnderWater node of the Main node is where i instance it:

  • Main (Node)
    • WaterSurface (Node2D)
    • UnderWater (Node2D) (has script)

This is the script for it:

var eggpreset = load("res://nodes/Egg.tscn")

func _process(delta):
if Input.is_action_just_released("ui_accept") and get_node(".").visible == true:
	var egg = eggpreset.instantiate()

Edit: Downgrading back to 4.1 seems to do the trick but if anyone has an explanation for this i will gladly hear it!

There were some changes regarding mouse-entered/exited merged for 4.2. I don’t see any obvious problem in your code, but in order to properly investigate the reason, a minimal reproduction project would be necessary.

Please open a bug report on Github, so that we can investigate, if this is a regression or an intended change.

For reference:

I had same problem too. Then I turn off mouse filter in UI node