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?
Answer by Elielson · Aug 25, 2020 at 05:34 PM
Hello Palicinic,
hit.collider.name, solve your problem?
Answer by highpockets · Aug 25, 2020 at 10:50 PM
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>();
Your answer
Follow this Question
Related Questions
Need Help With Collider Script. 2 Answers
Why is my trigger collider acting like a normal collider? 1 Answer
C# OnTriggerEnter Issue 3 Answers
GameObject not colliding properly with a collider! 3 Answers
Help with Trigger Colliders.. 0 Answers