bevyengine / bevyengine/bevy

`PickingInteraction` randomly switch to `None` even when hovered

Open
#19,465 5 comments 0 reactions 0 assignees View on GitHub
A-Picking C-Bug C-Usability D-Modest S-Needs-Reproduction X-Uncontroversial
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

0.16

## What you did

```rust
/// Workaround for #19464 change detection broken on [`PickingInteraction`].
#[derive(Component)]
struct PrevPickingInteraction(pub PickingInteraction);

fn save_prev_picking_interaction(
mut query: Query<(Entity, &PickingInteraction, &mut PrevPickingInteraction)>,
) {
for (e, pi, mut ppi) in &mut query {
trace!("hover: e={:?} prev={:?} cur={:?}", e, ppi.0, *pi);
ppi.0 = *pi;
}
}

app.add_systems(First, save_prev_picking_interaction);
```

## What went wrong

The target `Mesh2d` is a large-ish rectangle, so there's no change the mouse accidentally leaves it. When slightly moving the mouse around a few pixels, I randomly get a `None` for 1 frame, immediately followed by a `Hovered` again. This looks like a race condition or timing issue where 1 frame would be skipped for example, and would not detect the mouse temporarily. I'm already working around #19464, and now it seems I also need averaging/smoothing over multiple frames to get a stable hover/non-hover (mouse enter/leave) pair of events. This makes using `bevy_picking` pretty cumbersome.

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Start by reproducing the issue with the shown PickingInteraction workaround, then trace the bevy_picking hover update path and its First-stage timing around Mesh2d targets. Done means the pointer remains hovered without an intermittent None, with regression coverage for the reported movement pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.