godotengine / godotengine/godot

Mouse Stop Filter unexpectedly triggers Area3D's mouse_enter signal after triggering expected mouse_exit signal

Open
#87,322 1 comment 0 reactions 0 assignees View on GitHub
bug topic:input
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in
- v4.2.1.stable.official [b09f793f5]
- v4.3.dev (96296e476)

### System information

Godot v4.2.1.stable - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 (NVIDIA; 31.0.15.3734) - Intel(R) Core(TM) i5-14600K (20 Threads)

### Issue description

## Overview
The issue is that an `Area3D`'s `mouse_enter` signal is unexpectedly emitting immediately after its `mouse_exit` signal emits. I don't think this is the expected behavior because in my **MRP** I can reproduce this only seconds after demonstrating that it does not always occur.

## Details
#### Setup
The **MRP** has a `MeshInstance` (a sphere with radius=1) and a `Button` in the center of the screen so that it partially overlaps the `MeshInstance`. The `Button`'s mouse filter is set to **stop**, and the `MeshInstance` has an `Area3D` (with a collision body that matches the mesh) which triggers a print statement when the mouse enters or exits the `Area3D`.
#### Issue
What I expect to see, and what happens some of the time, is that when the mouse hovers over the `Area3D` the scene should print "MOUSE: ENTER", and when the mouse continues to move so that is hovers over the button (which overlaps the `Area3D`) the scene should print "MOUSE: EXIT". In some case, however, there is an additional (and unexpected) "MOUSE: ENTER" that gets printed right after the expected "MOUSE: EXIT"

### Steps to reproduce

Using the MRP:
1. Launch the app
2. Hover over the sphere
- See that the console prints "MOUSE ENTER"
3. Hover off of the sphere (not going over the button)
- See that the console prints "MOUSE EXIT"
4. Hover over the sphere, but quickly continue to move the mouse so you also hover over the button.
- This step doesn't always produce the unexpected behavior. I don't know exactly what causes the unexpected behavior, but if you keep trying I think you'll be able to see it (see the attached recording)

**Observed behavior:**
After step 4, I sometimes see 3 new print statements:
```
MOUSE: ENTER
MOUSE: EXIT
MOUSE: ENTER
```

**Expected behavior:**
I expect to always see only 2 new print statements
```
MOUSE: ENTER
MOUSE: EXIT
```

### Screen Recording (with console print statements)

https://github.com/godotengine/godot/assets/8028662/156120e9-372f-49fc-a2a6-75844a009ac1

### Minimal reproduction project (MRP)

[minimal_mouse_hove_example.zip](https://github.com/godotengine/godot/files/13971902/minimal_mouse_hove_example.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the attached minimal reproduction project and reproduce the Area3D mouse_enter/mouse_exit sequence using the overlapping Button with mouse_filter set to stop. The issue is resolved when moving across the sphere and button consistently produces only the expected ENTER and EXIT signals, without an extra ENTER.

Written by the indexing model from the issue text.

Assessment

Tech stack
godot
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.