void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { controller.ChangeCoin(1); Destroy(gameObject); } }
void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { if (controller.currentCoin < controller.maxCoin) { controller.PlaySound(collectedClip); Destroy(gameObject); controller.ChangeCoin(1); //Destroy(gameObject); } } }