Multiple colliders index problem,i have multi colliders, which collider is my?

Hey guys,

I have project but in have a problems.
For example, i have 10 enemies in my project. Enemy prefab is “botAI” script using;

if (hit.collider.tag == "enemys")
       {
          _enemyAI = _enemys[x].GetComponent<botAI>();
          _enemyAI._health -= 15;
       }

How do i know which enemy is?

How do i found x?

Hello Palicinic,

hit.collider.name, solve your problem?

You question is a bit confusing, but as I see it, you’re already checking if it is an enemy when you compare the tag. So, hit.collider.gameObject is your enemy I would think and you could get the component with hit.collider.gameObject.GetComponent<botAI>();