#Cursor reticle is delayed by 1 frame

1 messages · Page 1 of 1 (latest)

stable goblet
#

I made a reticle for my game that follows the mouse cursor (by setting its position in the _input() callback). This works fine, except that the reticle's position updates one frame later than the real (system) cursor does. This makes the reticle feel "sluggish". I was wondering if there was any way to fix or mitigate this delay, as it's pretty annoying. (video attached for an example)

#

Cursor reticle is delayed by 1 frame

stable goblet
#

bump

golden yarrow
#

Godot's _input(event) reacts only when an InputEvent is sent by the OS.
_process(delta) runs at each frame.

To me it seems like you want to have this run indefinitely. If that's the case, try checking for the input in your _process() function with the Input Singleton

robust torrent
#

What does your 'cursor position' script look like? Are you updating the value
as-is, or are you running it through an interpolation function?

While not necessarily as efficient, you can opt to use
'CanvasItem::get_global_mouse_position' or 'DisplayServer::mouse_get_position
[for screen-space coords]' to grab the user's cursor position directly from
anywhere.

Relevant docs:
https://docs.godotengine.org/en/stable/classes/class_displayserver.html#class-displayserver-method-mouse-get-position

https://docs.godotengine.org/en/stable/classes/class_canvasitem.html#class-canvasitem-method-get-global-mouse-position

stable goblet