Bullet destroy 2 game object intent one Unity 2D
When my bullet Collide with Ball if there is 2 Ball at near or same position all object destroy at same time. I set in my script when bullet collide other then player it will be destroy.
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;
}
}
Yerrow destroy himself when collide other then player
private void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag != "Player")
{
Destroy(this.gameObject);
player.CanFire = true;
}
}
Comment
Your answer
Follow this Question
Related Questions
Unity 2D rotation not smooth? 0 Answers
Unity Gradle Build Error 2019.3.10f 0 Answers
OnMouseDown not working! 0 Answers
Trigger enter and directly Exit 0 Answers