Godot Version
4.4.1 on Windows 11
Question
Hey everyone,
Lately, I’ve been struggling to implement a smooth drag-and-drop mechanic using the mouse. Most of the solutions I’ve found and tried still have noticeable lag. After testing several approaches, the only one that effectively removes lag is by using a custom mouse cursor - and I’m okay with its limitations for my use case.
My logic flow:
- On left-click on a
TextureRect
node:
- Hide the
TextureRect
- Set the mouse cursor to its texture
- While dragging
- Continuously update the cursor position (still some lag, but acceptable as it is not visible)
- On second left-click (to drop):
- Disable input
- Show the
TextureRect
node - Wait briefly
- Reset the cursor to default
- Enable input
This setup mostly works well, but I’m still seeing a slight flicker of the texture when moving the mouse quickly right as the drop occurs. The code can be seen on pastebin. It can tested by creating a scene with a root of TextureRect
node and adding the script to the node.
Question
Any ideas or suggestions on how to clean up the last bit of visual glitch? Or maybe propose another method of implementation?
Any help will be greatly appreciated!