Target Priority

Hello everyone.
I’m currently working on a dungeon crawler game and I have a level part that is going to be a wave of enemies prioritizing the attack of an object istead of the player. I wanted to create something like a random number, that way thy would attack the object more than the player.
Anyone can help me to how I can create a target priority system?
Thank you.

I think you can maybe come up with a functionality that creates a min distance for the enemy to attack the player, but as the enemies spawn, make that distance a random float:

public class Enemy : MonoBehaviour
{
    private float randomDist;
   
    private Transform player;
    
    private void Start()
    {
        randomDist = Random.Range(4.0f, 20.0f);
        player = GameObject.FindWithTag(“Player”);
    }
    private void Update()
    {
        if(Vector3.Distance(transform.position, player.position) <= randomDist)
        {
            //Attack player
        }
        else
            //Look for other opponents to attack
    }
}