void OnTriggerEnter2D(Collider2D col) { switch (col.gameObject.name) { case "Trex": TrexEnemyScript tes = col.gameObject.GetComponent <TrexEnemyScript> (); tes.GetDamaged(); break; } Destroy(gameObject); }
void Awake() { currentInstance = Instantiate(generatorPrefab, transform.position, transform.rotation, entityGroupRef); switch (generatorPrefab.name) { case "Trex": TrexEnemyScript tes = currentInstance.GetComponent <TrexEnemyScript> (); tes.eg = this; break; } currentInstance.SetActive(false); }
void OnTriggerEnter2D(Collider2D col) { if (col.tag == "AliveArea") { if (currentInstance == null) { currentInstance = Instantiate(generatorPrefab, transform.position, transform.rotation, entityGroupRef); switch (generatorPrefab.name) { case "Trex": TrexEnemyScript tes = currentInstance.GetComponent <TrexEnemyScript> (); tes.eg = this; break; } } else { currentInstance.SetActive(true); } canDisableInstance = false; } }