Only want rotation on y axis

I have a script so when the player does a 180, a screen effect happens as they turn around and hits 100% when the player does a full 180. The problem is its taking not only the y rotation but also the x, I only want to take the Y rotation .
heres the script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.Universal;
using static UnityEngine.GraphicsBuffer;

public class FullScreenTestController : MonoBehaviour {


    private Quaternion startDirection;
    private Quaternion _180Direction;
    private Camera _camera;
    
    public Transform target;
    public Transform player;

    [Header("Time")]
    [SerializeField] private float _hurtDitherFadeInTime = 5;
    [SerializeField] private float _hurtColorResFadeInTime = 5;



    [Header("References")]
    [SerializeField] private ScriptableRendererFeature _fullscreeneffect;
    [SerializeField] private Material _material;

    private int _DitherSpread = Shader.PropertyToID("_DitherSpread");
    private int _ColorResolution = Shader.PropertyToID("_ColorResolution");

    private const int DITHERSPREAD_START_AMOUNT = 0;
    private const int COLORRESOLUTION_START_AMOUNT = 1000;


    private void Start() {

      //  _fullscreeneffect.SetActive(false);
        startDirection = Camera.main.transform.rotation;
        _material.SetFloat(_DitherSpread, DITHERSPREAD_START_AMOUNT);
        _material.SetFloat(_ColorResolution, COLORRESOLUTION_START_AMOUNT);

    }

    private void Update() {

        if (Input.GetKey("e")) {
            //  _fullscreeneffect.SetActive(true);
            StartCoroutine(Death());
        }
       
        _180Direction = Camera.main.transform.rotation;

        float angle = Quaternion.Angle(startDirection, _180Direction);

        float lerpedDither = Mathf.Lerp(DITHERSPREAD_START_AMOUNT, -0.09f, (angle/4  / 180));
        float lerpedColorRes = Mathf.Lerp(COLORRESOLUTION_START_AMOUNT, 1000f, (angle/4 / 180));

        _material.SetFloat(_DitherSpread, lerpedDither);
        _material.SetFloat(_ColorResolution, lerpedColorRes);
        Debug.Log(angle);
        }








    
    private IEnumerator Death() {
        _fullscreeneffect.SetActive(true);
        _material.SetFloat(_DitherSpread, DITHERSPREAD_START_AMOUNT);
        _material.SetFloat(_ColorResolution, COLORRESOLUTION_START_AMOUNT);

        float elapsedTime = 0;
        while (elapsedTime < _hurtDitherFadeInTime) {
            while (elapsedTime < _hurtColorResFadeInTime) {

                elapsedTime += Time.deltaTime;

                float lerpedDither = Mathf.Lerp(DITHERSPREAD_START_AMOUNT, -0.09f, (elapsedTime / _hurtDitherFadeInTime));
                float lerpedColorRes = Mathf.Lerp(COLORRESOLUTION_START_AMOUNT, 0f, (elapsedTime / _hurtColorResFadeInTime));

                _material.SetFloat(_DitherSpread, lerpedDither);
                _material.SetFloat(_ColorResolution, lerpedColorRes);

                yield return null;
            }

        }

    }
}


Just get the y component of the rotation like “Quaternion.Euler(camera.main.transform.rotation).y” and work with that. Unless I’m missing something seems like the easiest way to go.

Your best bet is to have local-only float variable to represent heading, then change and clamp that floats, and finally drive .localRotation of the parts on their correct Transform axis.

All about Euler angles and rotations, by StarManta:

https://starmanta.gitbooks.io/unitytipsredux/content/second-question.html