Help! I want to make a following camera but in with Y position is constant ?

i wanna make the camera follow my object with fixed distance between them ,but without changing the y position (Distance of y axis between object and camera ) . Knowing that the object moves right and left and jumps
thanks a lot.

The most simple way I can think off is something like this…

public class Follow extends MonoBehaviour {
    Transform target;
    Vector3 offset;

    void Update() {
        Vector3 newPosition = new Vector3(target.positions.x + offset.x, offset.y, target.position.z + offset.z);
        transform.position = newPosition;

Attach that script to the camera, drag and drop the object that should be followed as the target and set the offset to the fixed distance between the camera and the object.

This should work fine

public class CameraFollow : MonoBehaviour {

	private GameObject player;
	//public float cameraSpeed = 5.0f;

	// Use this for initialization
	void Start () {
		player = GameObject.FindGameObjectWithTag ("Player");
	// Update is called once per frame
	void FixedUpdate () {
		//X position follow
		Vector3 camPos = transform.position;
		camPos.x = player.transform.position.x;
		//camPos.z = player.transform.position.z; // only use if you want to follow from the player's z coordinate
		transform.position = Vector3.Lerp (transform.position, camPos, 15 * Time.fixedDeltaTime);