Mouse trail has 1-frame delay, is there anything I can do?

Godot Version

4.2.1 stable


Hey, so I’m using a Line2D to make a mouse cursor trail, but as you can see in this gif:
cursor delay
EDIT: Yeah turns out the gif didn’t pick up my mouse cursor, but there’s almost always a gap between my mouse cursor (which is a white dot the same thickness as the beginning of the trail to blend in with the trail) and the trail
It has a pretty egregious 1-frame delay.

The docs say using a script to set the cursor would have a 1-frame delay

So, my question is. Is there anything I can do? Is there some built-in thing I don’t know about?

I’ve tried predicting where the mouse will be using the velocity in _input(event), but people don’t move their mouses in a straight line.

Right now it’s just adding to the Line2D every time the player moves their mouse in _input(event) or if they didn’t move their mouse then it updates the position in _process(delta) so that the other thing in _process(delta) can remove from the end of the trail

So far I see my only options to be remove the trail or submit a feature request for built-in custom mouse trails, if it’s even possible.

There are two types of mouse cursor, hardware cursor and software cursor.

A hardware mouse cursor gets special treatment by the OS to avoid delay but is limited to a simple icon. That is was you set in your ProjectSettings or with Input.set_custom_mouse_cursor().

A software mouse cursor is whatever you want it to be (e.g. in this case a Line2D), but always lags visually a few frames behind the actual mouse position. There is nothing you can do about this delay other than minimising it, and hiding it behind your visuals. E.g. most games with “fancy” software mouse cursors have very slow movement or unprecise visuals so that users do not see the delay as strongly.

1 Like

There is nothing that can be done about this without introducing potential errors (such as with the extrapolation you attempted), but you can mitigate input lag via other means such as disabling V-Sync (and setting a framerate cap to prevent excessive CPU/GPU utilization).

Hardware mouse cursors don’t have a delay but are limited to fixed images, so you wouldn’t be able to create the effect you want.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.