Help with gamemanager and health so that when you die, you get a game over screen

I’m having trouble getting it so that when you die, you get a gameover screen (which were the scene switches when you die) and i cant get it to work, here is what i have soo far

this is my gamemanager script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
    public static GameManager gameManager { get; private set; }

    public UnitHealth _playerHealth = new UnitHealth(100, 100);

    void Awake()
    {
        if (gameManager != null && gameManager != this)
        {
            Destroy(this);
        }
        else
        {
            gameManager = this;
        }
    }
    void Update()
    {
        if (GameManager.gameManager._playerHealth = GameManager.gameManager._playerHealth(0,0))
        {
            SceneManager.LoadScene(2);
        }
    }
}

and this is what i have in a script called PlayerBehavior (It has to do with health as well)

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

public class PlayerBehavior : MonoBehaviour
{
    [SerializeField] Healthbar _healthbar;

    public InputActionReference takedamage;
    public InputActionReference heal;
    private PlayerInput playerInput;

    private InputAction takedamageAction;

    private void OnEnable()
    {
        takedamage.action.started += TakeDamage;
        heal.action.started += Heal;
    }

    private void TakeDamage(InputAction.CallbackContext obj)
    {
        PlayerTakeDmg(20);
        Debug.Log(GameManager.gameManager._playerHealth.Health);
    }
    private void Heal(InputAction.CallbackContext obj)
    {
        PlayerHeal(20);
        Debug.Log(GameManager.gameManager._playerHealth.Health);
    }

    public void PlayerTakeDmg(int dmg)
    {
        GameManager.gameManager._playerHealth.DmgUnit(dmg);
        _healthbar.SetHealth(GameManager.gameManager._playerHealth.Health);
    }

    private void PlayerHeal(int healing)
    {
        GameManager.gameManager._playerHealth.HealUnit(healing);
        _healthbar.SetHealth(GameManager.gameManager._playerHealth.Health);
    }

    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.name == "EnemyBullet")
        {
            PlayerTakeDmg(20);
        }
        if (collision.gameObject.tag == "EnemyBullet")
        {
            PlayerTakeDmg(20);
        }
    }
}

i am also using the new unity input system

Please learn to use code tags, please explain more as to what specifically you are having problems with

i forgot the code tags, mb, but basically what im trying to do is when UnitHealth(100, 100) == 0 it will switch scenes, 22 - 29 is what im having trouble right now

without knowing what UnitHealth is, its not easy to know…

One big problem I see: on line 24 you’re using a single equals sign, and so you’re performing an assignment rather than a comparison.

Its a script, i forgot to put the script in the first post, Here

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

public class UnitHealth
{
    // Fields
    int _currentHealth;
    int _currentMaxHealth;

    // Properties
    public int Health
    {
        get
        {
            return _currentHealth;
        }
        set
        {
            _currentHealth =  value;
        }
    }
        public int MaxHealth
    {
        get
        {
            return _currentMaxHealth;
        }
        set
        {
            _currentMaxHealth =  value;
        }
    }

    // Constructor
    public UnitHealth(int health, int maxHealth)
    {
        _currentHealth = health;
        _currentMaxHealth = maxHealth;
    }

    // Methods
    public void DmgUnit(int dmgAmount)
    {
        if (_currentHealth > 0)
        {
            _currentHealth -= dmgAmount;
        }
    }
    public void HealUnit(int healAmount)
    {
        if (_currentHealth < _currentMaxHealth)
        {
            _currentHealth += healAmount;
        }
        if (_currentHealth > _currentMaxHealth)
        {
            _currentHealth = _currentMaxHealth;
        }
    }
}

@Chubzdoomer has nailed the obvious, if that wasnt it, then you should debug it

this helped, but i also needed to reference it from gamemanager not unithealth