My bullets hits many colliders instead fo one.
Hi, here is my problem.
I have a 2d platform game. I have two identical gameobjects with colliders, they are moving from right to the left while I am shooting at them. There is a place where all enemies have to stop. And there are cases when they are in the same position with the same colliders. So we practically see them as one object. And in this case when my bullets hit them, all enemies die. What I need to do is choose one of them and kill only one and I have no idea how to do that.
Private void OnCollisionEnter2D(Collision2D hit)
{
if (hit.transform.tag == "bullet")
{
Invoke("destroyy", 4);
}
}
First image : Enemies coming from right to left;
Second image: Enemies(10 of them) are in the same position. When the arrow hits them, all of them die.
Your answer
Follow this Question
Related Questions
Selective Collision Detection 2 Answers
Smoothing collision rate 1 Answer
My collision is not detecting 1 Answer
Best way to do Collision detection when you have multiple enemies/allies around you 0 Answers
How to detect a collision. Coming back to using Unity after taking a break for a few years. 0 Answers