////////////////////////////////////////////////////////////////////////////////////////////////////////// void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.name == "player" && this.gameObject.activeSelf || collision.gameObject.name == "player_idle" && this.gameObject.activeSelf ) { Player tempPlayer = collision.GetComponent <Player>(); //Here we call function foreach (var item in poisonBubble) { Poison_Bubble tempPoisonBubble = item.GetComponent <Poison_Bubble>(); tempPoisonBubble.gameObject.SetActive(true); tempPoisonBubble.randomRot = Random.Range(1, 5); tempPoisonBubble.transform.position = tempPlayer.transform.position; tempPoisonBubble.SetWorldPosition(collision.transform.position.x, collision.transform.position.y); //tempPlayerCopy.ScaleControll(tempPlayerCopy.playerCopyBubbleSize); //tempPlayerCopy.lifeTime = 10; //tempPlayerCopy.timer = 3; //tempPoisonBubble.ApplySpeedRB(gameManagerRef.helperRef.TakeRandomPosition()); } this.gameObject.SetActive(false); lifeTime = 0; gameObject.transform.position = lootContainer.transform.position; gameManagerRef.loot.Remove(this.gameObject); Destroy(this.gameObject); } }
void DestroyObject() { for (int i = 0; i < poisonBubble.Count; i++) { Poison_Bubble tempPoisonBubble = poisonBubble[i].GetComponent <Poison_Bubble>(); tempPoisonBubble.DestroyObject(); } Destroy(this.gameObject); }