how determine if the player is nearby when clicking on a game object to ?

Hello, I have 11 cards and when I click on the enemy cards I would like to determine if the player is nearby. I tried to solve this problem by throwing 4 rays in different directions from the enemy cards, but for some reason only the bottom card works for me and all the others do not. If there is an opportunity, someone can roughly tell in what ways this can be implemented.

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

public class cardclic : MonoBehaviour
    public float distanceheight;
    public float distancewidth;
    // Start is called before the first frame update
    void Start()
    // Update is called once per frame
    void Update()
    void OnMouseDown()
        Physics2D.queriesStartInColliders = false;
        RaycastHit2D hitup = Physics2D.Raycast(transform.position, transform.position + Vector3.up * transform.localScale.x * distanceheight);
        RaycastHit2D hitlefl = Physics2D.Raycast(transform.position, transform.position + Vector3.left * transform.localScale.x * distancewidth);
        RaycastHit2D hitrignt = Physics2D.Raycast(transform.position, transform.position + Vector3.right * transform.localScale.x * distancewidth);
        RaycastHit2D hitdown = Physics2D.Raycast(transform.position, transform.position + Vector3.down * transform.localScale.x * distanceheight);
        if ( hitup.collider.tag == "Player" || hitlefl.collider.tag == "Player" || hitrignt.collider.tag == "Player" || hitdown.collider.tag == "Player")

    private void OnDrawGizmos() // луч чтобы был виден разработчику
        Gizmos.color =;
        Gizmos.DrawLine(transform.position, transform.position + Vector3.up * transform.localScale.x * distanceheight);
        Gizmos.DrawLine(transform.position, transform.position + Vector3.left * transform.localScale.x * distancewidth);
        Gizmos.DrawLine(transform.position, transform.position + Vector3.right * transform.localScale.x * distancewidth);
        Gizmos.DrawLine(transform.position, transform.position + Vector3.down * transform.localScale.x * distanceheight);

Rather than raycast, for your case I’d use the overlap static function you can find on the Physics2D. There are different shapes with the overlap function, I believe the circle is the one that fits your scenario the most.

The way this works is basically as if it created a collider with the given attributes but just for the check (non persistent on the scene) and returns all colliders it collides with. Then the same way you did with the raycast, you just check if some of those colliders have the player tag.