How to make the Crosshair follow delayed

Hi guys,
I’ve run trough several posts and other questions here but can find me a helpful answer.
What I trying to achieve is that the crosshair follows the camera with a little delay.

Example Video: 1

I want it to be like that HUD and not animated. I don’t need the walking shake since my Player wont walk in my game.

Here is my Code so far:

using UnityEngine;
using System.Collections;

public class DynamicGUI : MonoBehaviour {

	public float speed = 0.5F;
	public float centerSpeed = 0.0001F;
	public Transform camera;
	public Texture crosshair;

	private float slowX;
	private float slowY;
	private float lastX;
	private float lastY;
	private float offsetX;
	private float offsetY;
	private float xValue = 0.0F;
	private float yValue = 0.0F;

	// Use this for initialization
	void Start () {
	// Update is called once per frame
	void Update () {

		offsetX = Input.GetAxis ("Mouse X") * Time.deltaTime;
		offsetY = Input.GetAxis ("Mouse Y") * Time.deltaTime;

		lastX = camera.rotation.x;
		lastY = camera.rotation.y;

		slowX = Mathf.SmoothDamp(-offsetX, 0,  ref xValue, centerSpeed);
		slowY = Mathf.SmoothDamp(-offsetY, 0,  ref yValue, centerSpeed);
	void OnGUI (){
		GUI.DrawTexture (new Rect(Screen.width/2 + slowX * Screen.width, Screen.height/2 + slowY * Screen.height, 16, 16), crosshair);
		GUILayout.Label("SlowX: " + slowX);
		GUILayout.Label("SlowY: " + slowY);
		GUILayout.Label("Last X: " + lastX);
		GUILayout.Label("Last Y: " + lastY);
		GUILayout.Label("Offset X: " + offsetX);
		GUILayout.Label("Offset Y: " + offsetY);

So I got it to center a bit slower but I cant get it smooth and more delayed.
Maybe I’m stuck within a method which cant be used for this.
I hope you can help me out at this. I am familiar with java and C#.

Best regards

The first approach that comes to mind is to track the world position some distance in front of the camera, and then Lerp() from that world position (translated to screen coordinates) to the center of the screen. Not sure it is any better approach than the one you are doing, but here is a bit of example code:

using UnityEngine;
using System.Collections;

public class Bug25b : MonoBehaviour {
	public Texture crosshair;
	public Camera camera;
	public float speed = 7.0f;
	public float maxDrift = 1.25f;
	private Vector3 lastPos;
	private Rect rect;
	private Vector3 center = new Vector3(0.5f, 0.5f, 10.0f);
	void Start() {
		if (camera == null) {
			camera = Camera.main;
		lastPos = camera.ViewportToWorldPoint (new Vector3(0.5f, 0.5f, 10.0f));
		rect = new Rect(0,0,crosshair.width,crosshair.height);
	void OnGUI() {
		if (Event.current.type == EventType.Repaint) {
			Vector3 centerPos = camera.ViewportToWorldPoint (center);
			// Clamping code
			Vector3 v = lastPos - centerPos;
			v = Vector3.ClampMagnitude (v, maxDrift);
			lastPos = centerPos + v;
			Vector3 lastScreenPos = camera.WorldToScreenPoint(lastPos);
			lastScreenPos.y = Screen.height - lastScreenPos.y; = Vector3.Lerp (lastScreenPos, new Vector3(Screen.width/2, Screen.height/2, 0), Time.deltaTime * speed);
			lastPos =;
			lastPos.y = Screen.height - lastPos.y;
			lastPos.z = 10.0f;
			lastPos = camera.ScreenToWorldPoint(lastPos);
		GUI.DrawTexture(rect, crosshair);