Can't attach Animator in public Animator script parameter. Help.

Hi,
I’m trying to attach my enemy animator to my enemy combat script on my enemy prefab yet when I try add it only the enemy gameObject is able to be added.
Even when i do drag and drop my enemy prefab into that parameter my script throws up a error saying it can’t access my enemy animator.

My enemy script im trying to add the animator to:

public class EnemyCombat : MonoBehaviour
{

    public Combat combat;
    public int health;
    public int curHealth;
   
    public Animator eAnim;
    public bool isDead;
   
    private GameObject enemy;
    public GameObject target;
    NavMeshAgent nM;
    public SphereCollider attackRange;
   
    public BoxCollider sword;

    public void Start()
    {
        curHealth=health;
        print(curHealth);
        enemy = gameObject;
        nM=gameObject.GetComponent<NavMeshAgent>();
       
      
    }
    public void Update()
    {

       
        OnTriggerStay(attackRange);

        OnTriggerEnter(sword);

        OnTriggerExit(attackRange);
        //Death();

       
           
       
    }

    public void Death()
    {
       
        eAnim.SetBool("Death", true);
        nM.SetDestination(enemy.transform.position);
        StartCoroutine(Died());

    }

    IEnumerator Died()
    {
        yield return new WaitForSeconds(3);
        Debug.Log("despawn");
        Destroy(enemy);
    }

    public void DamageEnemy(int damage)
    {
        curHealth -= damage;
        print(curHealth);
        print(damage);
        if (curHealth <= 0)
        {
            Death();
        }
    }


    public void OnTriggerStay(Collider other)
    {

      
        if (other.gameObject.tag == "Player")
        {
           
           // transform.LookAt(target.transform);
            eAnim.SetInteger("Attack", 1);
           
        }
    }

    public void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
           
            eAnim.SetInteger("Attack", -1);
        }

    }

    public void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            combat.health -= 5;
           
        }
    }

  


}

My player script trying to access it:

public class AttackCollision : MonoBehaviour
{
    // Start is called before the first frame update
    public EnemyCombat eC;
    SphereCollider c;
    public bool isHit = false;
    public float t=0.0f;
   
   

    void Start()
    {
        c = GetComponent<SphereCollider>();
        eC.curHealth=eC.health;
       
    }

    public void Update()
    {
       
        OnTriggerEnter(c);
       
    }

    public void OnTriggerEnter(Collider other)
    {
         t+= Time.deltaTime;
        //print(t);
        if (t>2.0f&&other.gameObject.tag == "Enemy"&&(Input.GetMouseButton(0)|| Input.GetMouseButton(1)||Input.GetKey(KeyCode.F)))
        {
            isHit=true;
            t = 0.0f;
            eC.DamageEnemy(25);
           
           
        }
        else
        {
           
            isHit = false;
        }
    }

 
   


}

Drag and drop either the whole object or just the component into the E Anim field in the inspector and it should fill itself in. That search box is for finding assets in the project and never works with components, I don’t even know why it’s an option.

EDIT: Wait are you trying to attach the enemy’s animator into the player’s field? That’s not going to work unless the enemy is also in the scene.

Yeah thanks i got it working by dragging the animator component attached to the enemy into that parameter and that worked whereas dragging the prefab into that parameter didnt for some reason even tho it still accessed the same animator.