When my bullet Collides with a Ball if there is 2 Balls at near or at the same position, all object get destroyed at same time. I set in my script when bullet collide with other then player it will be destroy.
I was trying to check every ball type with else if
if(other.gameObject.tag == "yerrow")
{
if (ballType >= 0 && ballType < 4)
{
clone1 = (GameObject)Instantiate(_ball, gameObject.transform.position, Quaternion.identity);
clone1.gameObject.GetComponent<Balloon_Behave>().ballMove = -4;
clone1.gameObject.GetComponent<Balloon_Behave>().transform.position = new Vector2(transform.position.x - Random.Range(0, 0.5f), transform.position.y - Random.Range(0,1));
clone2 = Instantiate(_ball, gameObject.transform.position, Quaternion.identity);
Destroy(this.gameObject);
}
else if (ballType == 4)
{
Destroy(this.gameObject);
}
Debug.Log("Yerrow COLl");
}
Yerrow Script Destroy himself
private void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag != "Player")
{
Destroy(this.gameObject);
player.CanFire = true;
}
}
EDIT NOTE : Every ball collides with bulled is destroy intent one. I want to destroy one object by one bullet