Rotating Camera Angle (C#)

Hello. Im using a C# script from a tutorial that allows your Camera to rotate around a game object. It’s working well, except it always points to my character’s feet. Its not locked to the character’s pivot because when I move the character’s position my camera continues to aim at the ground. Can anyone tell me how to aim the Camera to my character’s head?

here is the script:

using UnityEngine;
using System.Collections;

public class MouseAimCamera : MonoBehaviour {
    public GameObject target;
    public float rotateSpeed = 5;
    Vector3 offset;
    void Start() {
        offset = target.transform.position - transform.position ;
    }
    void LateUpdate() {
        float horizontal = Input.GetAxis("Mouse X") * rotateSpeed;
        target.transform.Rotate(0, horizontal, 0);
        float desiredAngle = target.transform.eulerAngles.y;
        Quaternion rotation = Quaternion.Euler(0, desiredAngle, 0);
        transform.position = target.transform.position - (rotation * offset);
        transform.LookAt(target.transform);
    }
}

Add an empty object to your character, move it to the head and use it as target for the camera.

Tried, no luck. The center of interest is still at the base of the ground. Which tells me its not the object pivot point that the camera is looking at, but the ground itself. Its like the code above makes the Camera look at 0 on the Y axis of world space. Regardless of where the Pivot is on any object. I’ve tested with a new GameObject and the character I have in the scene.

Any suggestions on what I can do on the code above to have the Camera look higher or lower?

Why dont you use MouseOrbit controller ?

I haven’t tried the MouseOrbit control, but I’ll look into it. Thanks!