void OnCollisionEnter2D(Collision2D other) { RocketBoyController thePlayer = other.gameObject.GetComponent <RocketBoyController>(); if (thePlayer != null) { thePlayer.Health(-2); } }
void OnTriggerEnter2D(Collider2D other) { RocketBoyController controller = other.GetComponent <RocketBoyController>(); if (controller != null) { if (controller.Lives < controller.maxLives) { controller.Health(1); Destroy(gameObject); controller.PlaySound(pickUp); } } }