Unity Frame Delay

I’m attempting to create my own cursor of sorts. Specifically, I’m setting an objects position to where the mouse points in the game world. This functions fine.

I have almost nothing else happening in the scene to cause lag though I’m sure that wouldn’t be the issue anyway.

The issue appears to be frame delay, where the object seems to lag behind the mouse pointer (using windows cursor atm). It floats around with about 0.2-0.3 seconds delay on the PC, 0.3-0.4 seconds on an android device I’m testing on.

I frapsed the footage and slowed it down to confirm my suspicions. What I see is the windows cursor updating 5 times before the object begins to move. That would be fine, if the object simply appeared where the mouse is. Instead, it appears at each of the 5 locations the mouse was at prior before reaching the mouse position.

It seems like the frames being rendered are causing the delay. Does anyone know how I can fix this?

I remember doing a lot of tweaking when I was working with dx9 before stumbling upon a solution… have the game update slower than the frame-rate (by 1 frame even). The delay was greatly reduced but I don’t think this is possible with unity…

I remember this is often related to the frame cache.
Try to disable prerendered frames either in Unity settings and in the graphic board control panel, just to be sure.

How can I disable pre-rendered frames in Unity? Google yields no results ><

Not at my pc now so I can’t check, watch at the project quality prefs.
But check the graphic board control panel first of all.

It made no difference. Well, I couldn’t disable pre-rendered frames… only set to 1-4. I set it to 1 and it made no difference, was using “Use 3D application settings”.

Quality settings don’t have an option for pre-rendered frames (I’m using unity 3.5 btw).

Try disabling vertical synchronization to update the frames faster:

QualitySettings.vSyncCount = 0;

It’s an old thread… but has anyone figured out how to request a lower ‘max pre-rendered frames’ from within a vsynced Unity build?

If the nVidia drivers are set to their defaults (Maximum pre-rendered frames: Application-controlled), then enabling vsync appears to add a very noticable 3-4 frames of lag.

It’s clearly visible if you do a PC build with vsync on, and run it in a window alongside the editor. If they’ve both responding to the same controller, you can see that the editor responds well before the vsynced build, and we’re not dealing with sub-frame latency, there’s several whole frames involved (I counted 3 frames in a case that I video captured at 60hz).

I’m assuming ‘application-controlled’ means that there’s some way that a native app can request a lower pre-rendered frame count, and that we’re getting the default (a value that gives best benchmark scores - better average FPS at the expense of a lot of latency!) - but is there a way to control it, rather than have to tell players to fiddle with GPU driver settings?