So i am making an Android game in which i want the Camera to follow the Character ONLY on the Z-Axis

I am using this script which makes the character follow the camera but the camera view shifts to the left side of the screen in play mode also it moves on the X-axis along with the character, which i don’t want. I want the camera to move only in the Z-axis, also the camera stutters a bit :
Here’s the script:

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {
public GameObject player;
private Vector3 offset;
// Use this for initialization
void Start () {
offset= transform.position;
}

// Update is called once per frame
void LateUpdate () {
transform.position = player.transform.position+offset;
}

}

y don’t use position for the camera. i mean like

camera.transform.position=new vector3(camera.transform.position.x,camera.transform.position.y,character.transform.position.z-//some distance what u need);