I have an overhead orthographic camera that I can pan and zoom on a map. My character’s position is shown using a DrawTexture. The problem is that when I’m panning around the screen, the DrawTexture is a frame or so behind my movement, so it looks like it’s jumping around. How can I keep the texture from lagging and jumping?
GUI code:
var Controller1 : GameObject; var PositionIcon : Texture; function OnGUI () { var IconX : float; var IconY : float; IconX = camera.WorldToScreenPoint(Controller1.transform.position).x; IconY = camera.WorldToScreenPoint(Controller1.transform.position).y; GUI.DrawTexture(Rect(IconX-10,Screen.height-IconY-10,20,20),PositionIcon,ScaleMode.ScaleToFit, true); }
Important part of panning script:
var fullMapCam : Camera;var panSpeed : float = zoomSize.025; if(Input.GetButton("Fire1")&&(Input.GetAxis("Mouse X")!=0||Input.GetAxis("Mouse Y")!=0)){ fullMapCam.transform.position.x -= Input.GetAxis("Mouse X")panSpeed; fullMapCam.transform.position.z -= Input.GetAxis("Mouse Y")*panSpeed; Screen.lockCursor = true; } if(Input.GetButtonUp("Fire1")){ Screen.lockCursor = false; }