I want a bool on my animator set to true or false when my player is above or below a certain threshold yet whenever i test it, the bool remains constant(The bool is "Player is above")

I set up a boss room for my game in Unity yet the bool remains constant no matter what
My script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Boss_1_Behaviour : MonoBehaviour
{
    public Animator anim;
    [Header("Area Detection")]
    public bool notabove;
    public float size1;
    public float size2;
    public LayerMask PlayerOnly;
    public Transform boxes;
    [Header("shooting")]
    public Transform Shootpoint;
    public GameObject Laser;
    public float totalshotwait;
    private float shotwait;
    // Start is called before the first frame update
    void Start()
    {
        anim = GetComponent<Animator>();
        shotwait = totalshotwait;
        return;
    }

    // Update is called once per frame
    void Update()
    {
        notabove = Physics2D.OverlapBox(boxes.position, new Vector2(size1, size1),  0, PlayerOnly);

        if (shotwait <= 0)
        {
            if (notabove == false)
            {
                anim.SetBool("Player is above", true);
                anim.SetBool("is shooting", true);
                shotwait = totalshotwait;
            }
            else if (notabove == true)
            {
                anim.SetBool("Player is above", false);
                anim.SetBool("is shooting", true);
                shotwait = totalshotwait;
            }
        }
        else if (shotwait > 0)
        {
            shotwait -= Time.deltaTime;
            anim.SetBool("is shooting", false);
        }
    }
    void OnDrawGizmosSelected() 
    {
        Gizmos.color = Color.red;
        Gizmos.DrawWireCube(boxes.position, new Vector2(size1, size2));
    }
}

I would guess that looking at your code you if would likeky be;

  • You haven’t set the player LayerMask in the inspector
  • The layermask on the player is not set
  • As you don’t set a z depth, the player and boss are at different Z positions.