Change position of third person follow camera

Hello, I have only just started using unity, and I am currently working on a third person follow camera. At the moment, the script for my camera works just fine except it keeps angling downwards to look at the character instead of where I want it to look. I’m pretty sure this is because in the script it is being told to look at the target (the character), but I’m having a hard time setting the target to be just about the character. Here’s my script at the moment:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LookAtCamera : MonoBehaviour
{
    public GameObject target;
    public float damping = 1;
    Vector3 offset;

    // Start is called before the first frame update
    void Start()
    {
        offset = target.transform.position - transform.position;
    }

    // Update is called once per frame
    void LateUpdate()
    {
        float currentAngle = transform.eulerAngles.y;
        float desiredAngle = target.transform.eulerAngles.y;
        float angle = Mathf.LerpAngle(currentAngle, desiredAngle, Time.deltaTime * damping);

        Quaternion rotation = Quaternion.Euler(0, desiredAngle, 0);
        transform.position = target.transform.position - (rotation * offset);

        transform.LookAt(target.transform);
    }
}

Here’s what it is doing as of right now:

And here is the desired result:

Any help would be greatly appreciated! Thank you!

Hi there!

you’re right, It’s because the transform the camera is looking at is right in the center of the player capsule.

I’m assuming it’s just the angle you want to change?

There area a few ways to fix this.
One solution is adding a child object to the player capsule called “target”/“Camera Target”/etc and setting that at a position above the player capsule. This then can be the transform the camera targets like this:

 public class LookAtCamera : MonoBehaviour
 {
     public GameObject lookTarget;
     public GameObject target;
     public float damping = 1;
     Vector3 offset;
 
     // Start is called before the first frame update
     void Start()
     {
         offset = target.transform.position - transform.position;
     }
 
     // Update is called once per frame
     void LateUpdate()
     {
         float currentAngle = transform.eulerAngles.y;
         float desiredAngle = target.transform.eulerAngles.y;
         float angle = Mathf.LerpAngle(currentAngle, desiredAngle, Time.deltaTime * damping);
 
         Quaternion rotation = Quaternion.Euler(0, desiredAngle, 0);
         transform.position = target.transform.position - (rotation * offset);
 
         transform.LookAt(lookTarget.transform);
     }
 }

This method would offer some adjustability and the child game object will move automatically with the parent game object.

I hope this helps.