How do I follow a gameobject with the camera

I need to follow a gameobject, only on the y axis. I have tried multiple other soloutions, none of which worked for my purpose.
Here is the outline of what I want to to do:
Rotate Left/Right with Q/E Respectively;
Stay at a set offset distance away from the player.
Smoothly rotate in a circle around the player.

Here is my current code:`using UnityEngine;
using System.Collections;

public class CameraBehaviourScript : MonoBehaviour
{
public GameObject Player;
private Vector3 offset;

void Start ()
{
    offset = transform.position;
}



void Update()
{

   
}
void LateUpdate () 
{
    transform.position = Player.transform.position + offset;
    transform.LookAt(Player.transform);
    //transform.rotation.Set(0, Player.transform.rotation.y, 0, 0);
    
    
}

}
`

My way of doing this before, would be to set the camera position based on the rotation keys, but I cant seem to find a way to make it work.

PS. Is there a way for me to do something like this?: transform.rotation.y = Player.transform.rotation.y;

Your method is fine, you’re just using the wrong values. Rotations are not stored as (x rotation, y rotation, z rotation). They are stored as Quaternions, so trying to take just the y component to keep the y axis rotation will not give the expected result. Instead, Quaternions have a EulerAngles method, which is used to get the Euler rotation (that is, (x,y,z) rotation), rather than the Quaternion values. By taking the y component of the Euler angles only, you can ensure that it remains fixed on the other two axes.

As to your other question, no, you can’t set only one component of the rotation. Not only would you again be setting the Quaternion value directly (which as I explained is a bad idea), but Unity uses properties to reference its fields, in order to return a copy of the data. Modifying that is nonsensical, as it isn’t really stored anywhere (except temporarily), and as it’s a copy of the original data, wouldn’t change anything anyway.

Use the smooth look at script from Unity, or even the third person controller has a script for the camera, allowing you to adjust height and distance from the character, as well as other various properties.

There are also a number of scripts here that may be useful (including a smoothfollow c# version)

http://wiki.unity3d.com/index.php/Scripts/Controllers

You really don’t need all of this , To make the camera follow a player you make the camera the gameobject’s child . This should also work for the rotation