One basic problem I’ve been running into a lot with Godot is properly using the mouse position. For some reason there seems to be a slight delay between the position being used and the actual mouse position.
Here’s a basic example:
The Godot logo is using this code to move to the mouse position:
func _process(delta):
position = get_window().get_mouse_position()
The arrow is using this code to point towards the mouse:
This is inherent to how the OS mouse cursor is drawn compared to any other window, and is not an issue exclusive to Godot. You can’t fix this entirely unless you replace the mouse cursor image with the sprite’s texture, which you can do using OS.set_custom_mouse_cursor(). The arrow will still appear to lag behind slightly though, which you could mitigate by making look_at() point towards the extrapolated (predicted) mouse cursor’s position instead of its current mouse position. Doing so will introduce some visible error when the mouse cursor speed changes quickly though, so the result may look shaky in motion.
If you can’t use hardware mouse cursors for some reason, see the suggestions to reduce Input lag in the documentation.