title: Camera always behind player in Unity3d
body: <p>I'm struggling with this for quit some time now. I have GameObject, being a sphere, which is my player on a 3d Terrain. I have a Camera which is always on a fixed distance from the player, follows it where it goes with below script:</p>
  
  <pre><code>public GameObject player;
  private Vector3 offset;
  
  
  // Use this for initialization
  void Start () {
      offset = transform.position - player.transform.position;
  
  
  }
  
  void LateUpdate () {
  
      transform.position = player.transform.position + offset;
  }
  </code></pre>
  
  <p>So far so good. However what I actually want is that the camera rotates with the player, so it always looks into the direction where the sphere is moving, but always stays behind the player at the same fixed distance, so that the player is always visible in the camera view.</p>
  
  <p>There are a lot of scripts available, but the problem with the onces I've seen so far is that the camera indeed rotate with the player, but because the player actually is a rolling sphere the camera view is rolling and turning as well. </p>
  
  <p>The best script I found so far is below, but this one has the same problem as the other onces, the camera rolls with the player.</p>
  
  <pre><code>public Transform target;
  public float distance = 3.0f;
  public float height = 3.0f;
  public float damping = 5.0f;
  public bool smoothRotation = true;
  public bool followBehind = true;
  public float rotationDamping = 10.0f;
  
  void Update () {
      Vector3 wantedPosition;
      if(followBehind)
          wantedPosition = target.TransformPoint(0, height, -distance);
      else
          wantedPosition = target.TransformPoint(0, height, distance);
  
      transform.position = Vector3.Lerp (transform.position, wantedPosition, Time.deltaTime * damping);
  
      if (smoothRotation) {
          Quaternion wantedRotation = Quaternion.LookRotation(target.position - transform.position, target.up);
          //Quaternion ownRotation = Quaternion.RotateTowards;
          transform.rotation = Quaternion.Slerp (transform.rotation, wantedRotation, Time.deltaTime * rotationDamping);
      }
      else transform.LookAt (target, target.up);
  }
  </code></pre>
  
  <p>Can anyone help me with this please?</p>