Billboard script that only rotates horizontally?

Hey, thanks for taking the time to help me. I’m very basic with Unity Scripting and C#.

Here’s a basic billboard script which rotates something to the direction of an attached camera. I was wondering if I can make it so that it only rotates the x-axis.

using UnityEngine;
using System.Collections;
 
public class CameraFacingBillboard : MonoBehaviour
{
    public Camera m_Camera;
 
    void Update()
    {
        transform.LookAt(transform.position + m_Camera.transform.rotation * Vector3.forward,
            m_Camera.transform.rotation * Vector3.up);
    }
}

I’m trying to make billboard enemies from sprites in a 3D world. However, there’s an issue with looking directly downwards from a high viewing point at the billboarded enemy as it looks like its laying down. Any help would be appreciated.

Set the object’s z rotation to 0 after your apply the LookAt rotation.

void Update()
     {
         transform.LookAt(transform.position + m_Camera.transform.rotation * Vector3.forward,
             m_Camera.transform.rotation * Vector3.up);
             Vector3 eulerAngles = transform.eulerAngles;
             eulerAngles.z = 0;
             transform.eulerAngles = eulerAngles;
     }