Disconnect between mouse movement and custom cursor

Hello,

I’m implementing custom cursor. With variable size and VFX.

Cursor is lagging in relation to real mouse position.
The faster you move the mouse - the bigger the lag.

Am I doing something wrong?
What is causing the lag?

void Update() {
      
    Vector2 CursorPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

    transform.position = CursorPosition;
}

Not answering the question you asked, but incase you didn’t know you can just set the default cursor to a Texture2D using SetCursor.

I have following concerns about this:
-Can I change cursor size/scale to custom value?
-How to manage particle effects on cursor? E.g. trace cursor movement with wisp.

  • I believe so, but you should test it yourself.
  • Don’t believe UI Trail/Particle renderers are a thing unless you make one yourself or buy one on the asset store. Don’t know about the best way, but you could have a camera take only input from the Trail/Particle object and then render it on a UI texture in your Canvas.
1 Like

I’m really confused at the moment.
Looks like lag existed in world space as well I simply didn’t notice it because system cursor wasn’t visible.

So what I’m experiencing is shown in this video (90 FPS is locked as in the game):

If you decrease youtube playback speed to 0.5 or lower you can see that pink line - my cursor is lagging behind system cursor.

At the moment I’m not sure if it’s normal or not.

P.S.:
I updated topic start to avoid confusion.

P.P.S:
I think I now started to getting it.
This lag is “normal” for custom software cursors. I remember this feeling of disconnect between mouse movement and cursor (lag) in some games but not other games.
It makes me really sad. :frowning:
I cannot go for hardware cursor. Effect that I need to achieve is mist-like radiation that starts inside the cursor. Radiation must start inside cursor according to design (so no combination of hardware cursor and VFX that follows it).

P.P.P.S.:
I kind of surprised to see this lag on a simple scene with only cursor on it. Even with unconstraint 500 FPS.
So it looks like I should either disregard VFX (which I really don’t want to do) or let the lag be.

Basically, there’s always some lag between the hardware cursor and what any bit of software is reading at that particular point in time. There’s a lot of complicated computery stuff as to why this happens. But the basics are that by the time Unity reads the hardware cursor position, does all the nonsense to render a frame, and spits it out to the screen, the hardware cursor has long since moved on.

This is generally the case with all games.

That’s my basic understanding at least. If I’m wrong, someone please correct me.

1 Like

Thank you very much spinew199!
You made me confident that it’s not my implementation issue.

It also explains why cursor has this “rubber” feeling when it moves along with the mouse if you move it slow but lags behind and catches up if you move it fast and stop.