Godot Version
v4.6.stable.official(Windows 11)
Question
Hi guys. I seemingly found a problem with the interaction between Control nodes and CollisionShape2D nodes regarding capturing mouse movement (entering and exiting the CollisionShape2D node), where depending on if V-Sync is on or off the detection becomes reliable or reliable, respectively. To recreate this I create a new project and place an Area2D node with a CollisionShape2D child (circular, raidius ~20 px); then place a Control node, i.e. Button, on top of it, so that they interesect; then write this in the root node:
extends Node2D
func _ready() -> void:
$Area2D.mouse_entered.connect(on_mouse_entered)
$Area2D.mouse_exited.connect(on_mouse_exited)
func on_mouse_entered():
print('mouse entered')
func on_mouse_exited():
print('mouse EXITED')
The layout in the scene:
Then, if I wiggle my mouse between the two nodes, so that it crosses from being above node to being above another node, I can get it, so that the console prints “mouse entered“ even though my mouse is on the button and no longer on the Area2D node (normally, once the mouse goes over the button, ‘mouse exited‘ is printed). This problem seemingly occurs only if V-Sync is off. If V-Sync is on, then there doesn’t seem to be a problem.
I can understand if V-Sync delays user input, but I don’t understand why V-Sync would affect what I would describe as ‘game logic‘. The problem may not be directly caused by disabling/enabling V-Sync, it is just what I have noticed.
This is relevant to my current project where I want to reliably detect when a mouse is on a CollisionShape2D objects, while they are overlayed with UI. If there is any fix it would be nice to know.
Thanks.
