Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Area 2d not detecting fast mouse movement #43474

Closed
KatoshiPL opened this issue Nov 12, 2020 · 4 comments
Closed

Area 2d not detecting fast mouse movement #43474

KatoshiPL opened this issue Nov 12, 2020 · 4 comments

Comments

@KatoshiPL
Copy link

Might be related to:
Fixed Area2d input events ignoring the top and left edge of rectangle shape #26103

Godot version:
Godot 3.2.3

OS/device including version:
Windows 7 and 10, both GLES2 and GLES 3

Issue description:
The issue is with two areas2d next to each other, they are not overlapping, there is even a 20 pixels gap between them, and the problem is that when you are moving your mouse fast from one area to another the mouse_entered signal is not working. I am using this areas to detect if mouse is over specific UI element on which i canoot set mouse filter to pass or stop(it need to be on ignore).

Steps to reproduce:
Create root node(node, node2d or control node) and as it childs add two UI panels one next to another, set mouse filter to pass or stop on both of them. Then for each panel create area2d with collision shape as a child. Set collision shape to rectangle and match the size with panel size. For both areas2d connect mouse_entered and mouse_exited signals to root node. Create variable mouse_over_UI in root node(bool) set it to false. The mouse_entered signal from each of areas2d should set this variable to true and mouse_exited to false. Remember to leave some gap(10-20 pixels) between areas/panels. Print mouse_over_UI variable in proces function to see the output/debug. Now to reproduce issue move mouse quickly from one panel to another and stop for a while, then move it very quick back to previous panel, repeat few times(remember that mouse need to be moved really fast to reproduce this bug) . As you can see while fast mouse moving, areas wont detect mouse entered sometimes which will give us console printing false while the mouse is over area2d.

Minimal reproduction project:

@mrjustaguy
Copy link
Contributor

mrjustaguy commented Nov 12, 2020

Please add a MRP, also, is it possible that you're somehow moving the mouse so fast that the position of the mouse is never IN the area?
for example (i'll use 1 axis for simplicity) Mouse starting point is 5, area is from 10 to 20, and in the frame you move your mouse by 30, meaning the next frame the mouse is at 35, meaning that between the 2 frames the mouse was only on position 5 and on position 35, none of which are in the 10 to 20 interval.
This happens because the motion the computer is seeing is jumpy as expected, it's just that the human eye isn't able to observe the changes that fast and blends them making the appearance of traveling from point 5 to point 35 across all the points... in the example above (tho the example above is very much oversimplified but the idea is what matters)

If this is indeed the problem and not something else causing it, there's a workaround you can do. make a RayCast that intersects Areas, and make sure it only raycasts with The area you need, and that others are excluded, and every time your mouse is moved, get the position of the mouse before and after, and use that as raycast start and end points, and that way use RayCast to get if the Mouse passed The Area.

@KatoshiPL
Copy link
Author

Will try to do the MRP as soon as possible...most probably upcoming weekend. I don't think i am moving mouse that fast as you described. I would say its just a fast move, similar to moves that we are doing all the time playing FPS games :)(or maybe I am superhuman haha). Like I say I will try to upload example asap and I will keep in mind your workaround with RayCast.

@Calinou
Copy link
Member

Calinou commented Nov 12, 2020

I think this is just yet another case of physics tunnelling. You need to perform continuous collision detection yourself (by performing checks on positions between the previous position and the current mouse position) to avoid that.

@pouleyKetchoupp
Copy link
Contributor

I'm closing this ticket since #43743 describes a similar issue with a MRP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants