Camera Movement Help

Hello I am seeking help with my camera. I want the camera to follow the player but not while it’s jumping. So the y coordinate is equal to zero, whilst the x and z variables follow the player’s transform position. Here’s the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraFollowScript : MonoBehaviour
{

    public Transform PlayerTransform;

    private Vector3 _cameraOffset;

    //[Range(0.01f, 1.0f)]
    public float SmoothFactor = 0.5f;

    public bool LookAtPlayer = false;

    // Use this for initialization
    void Start()
    {
        _cameraOffset = transform.position - PlayerTransform.position;
    }

    // LateUpdate is called after Update
    void Update()
    {
        Vector3 newPos = PlayerTransform.position + _cameraOffset;

        transform.position = Vector3.Slerp(transform.position, newPos, SmoothFactor);

        if (LookAtPlayer)
            transform.LookAt(PlayerTransform);

    }
}

In the update function after updating the transform.position you can zero the y component out, e.g.:
transform.position -= transform.up * transform.position.y;
This will move the camera down by its current y offset.
Or you create a new Vector3:
transform.position = new Vector3(transform.position.x, 0f, transform.position.z);

I really appreciate your post, however it’s causing the camera to not follow the player at all

Camera stuff can be really tricky to get right, and even slightly-off can feel jarring to the player, as if their head is being yanked or jerked.

Have you considered using the Cinemachine package from Unity? You can get it at the package manager at Window → PackageManager.