On_mouse_entered/exited doesn't work on instanced object

Godot Version

Godot 4.2.1

Question

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.
f4V7WYCUdL

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;
    print(inside)

func _on_mouse_exited():
    inside = false;
    print(inside)

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()
	    fish.set_global_position(Vector2i(get_viewport().get_mouse_position()))
	    get_tree().get_root().get_node("Main/UnderWater").add_child(fish)
	    queue_free()

“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()
	egg.set_global_position(Vector2i(get_viewport().get_mouse_position()))
	add_child(egg)

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