title: Camera follow the player only on his Z axis Unity 3D
body: <p>I made the script bellow for the camera to follow the player, but I don't want it to follow him on his X axis. So it should follow the player smoothly only on his Z axis. Any suggestions?</p>
  
  <p><strong>Camera Script:</strong></p>
  
  <pre><code>public Transform Ball;
  public float SmoothSpeed = 0.125f;
  public Vector3 offset;
  bool MoveCamera = true;
  
  
  void Start () {
  
  }
  
  
  public void FixedUpdate () {
  
      if(MoveCamera == true){
  
          Vector3 desiredPosition = Ball.position + offset;
          Vector3 SmoothedPosition = Vector3.Lerp(transform.position, desiredPosition, SmoothSpeed);
          transform.position = SmoothedPosition;
      }
  
  
      if (transform.position.z &gt;= 2f)
      {
          MoveCamera = false;
      }
  }
  </code></pre>