Sprite following mouse jumping around due to Cinemachine Virtual Cam

Hey there!

I have a sprite following the mouse cursor by a simple screen to world position conversion. I have a virtual camera following my player, now when the camera is static and I move the cursor it works fine and updates properly. But the problem arises when the camera moves to follow the player, the cursor jumps around (almost like a ghost sprite). Any idea what’s causing this or how to fix it? Do I need to lock the camera on the Z axis? Thanks in advance.

It most likely has to do with script execution order. Camera is moved in CinemachineBrain.LateUpdate. Make sure to position your cursor after that happens.

You can do it by editing the script execution order and putting your cursor script after CinemachineBrain (use LateUpdate, not Update, to position the cursor). Alternatively, you can add a handler to CinemachineCore.CameraUpdatedEvent, and put your cursor placement code in that handler.

See this thread: Tooltip updating it's position lags when Cinemachine moves (video)

3 Likes

That makes so much sense, appreciate the prompt reply and thank you!!