Mouselook in Update vs FixedUpdate + GUI.DrawTexture problem


1- Icon drawn over player correctly (not moving mouse)

2- Icon can’t keep up if mouse is moving (gets worse when mouse is moved faster)

The icons are drawn in another script in function OnGUI.

This is the base of my mouselook script:

transform.rotation *= Quaternion.Euler(-Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0);

Having it in Update ensures the mouselook behavior is consistent at any framerate, but I run into the problem shown in the screenshots. Having it in FixedUpdate ensures the icons are always drawn where they should be, but then mouselook behavior becomes inconsistent.

Any way I can have the best of both worlds?

Try doing the mouse look in the Update function, but then calculate the position of the icon in LateUpdate. LateUpdate executes after the changes made in Update have been committed and so you should get the correct positions of objects and avoid the lag. If this doesn’t fix the problem, perhaps you could post the whole script.

That did it – thanks!

LateUpdate seems useful to know, too :slight_smile: