void OnTriggerEnter2D(Collider2D other) { PlatformerController2D controller = other.gameObject.GetComponent <PlatformerController2D>(); if (controller != null) { controller.CollectCoin(); Destroy(gameObject); } }
void OnTriggerEnter2D(Collider2D other) { PlatformerController2D controller = other.gameObject.GetComponent <PlatformerController2D>(); if (controller != null) { controller.CollectCoin(); Doorway door = FindObjectOfType <Doorway>(); if (door != null) { door.CoinCollected(); } Destroy(gameObject); } }