RaycastHit2D hit all layermask in the scene

public LayerMask mask;
void Start()
{
//StartCoroutine(YY());
mask = LayerMask.GetMask(“chara”);
}

void Update()
{
    RaycastHit2D hit = Physics2D.CircleCast(transform.position, 1f, Vector2.zero, mask);
    if (hit.transform != null)
        Debug.Log(hit.transform.name);
}

The GameObject hit all gameobject with Collider2D component in the scene, Am i wrong?

Without knowing the names of your layers, is the name of the layer you want to cast against named “chara”

Perhaps try setting the mask in the inspector instead of in start()