diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index fe82fed2f7d..8412799f5d7 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -527,6 +527,11 @@ void Viewport::_process_picking() { if (to_screen_rect != Rect2i() && Input::get_singleton()->get_mouse_mode() == Input::MOUSE_MODE_CAPTURED) { return; } + if (!gui.mouse_in_viewport) { + // Clear picking events if mouse has left viewport. + physics_picking_events.clear(); + return; + } _drop_physics_mouseover(true);