title: How to make Camera follow only the horizontal movement (x axis) of the player?
body: <p>I am a super newbie in Unity and am learning by making my first game. I want the camera to follow the player, but only in the X axis. I had earlier made the camera a child of the player, but that didn't work as I wanted. So I whipped up a C# script to follow the player, as given below:</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class cameraFollow : MonoBehaviour
  {
      // Start is called before the first frame update
      void Start()
      {
          
      }
  
      // Update is called once per frame
      void Update()
      {
          transform.position = new Vector3(GameObject.Find(&quot;robot_body&quot;).transform.position.x, 0f, 0f);
      }
  }
  
  </code></pre>
  <p>However, this is showing only the blue background when run. Am I doing something wrong?</p>