private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "Main Cube") { mainCharacter character = other.gameObject.GetComponent <mainCharacter>(); if (!character.isPowerful()) { character.becomePowerful(timeActive); Destroy(gameObject); } } }
private void OnCollisionEnter(Collision collision) { speed = 0 - speed; if (collision.gameObject.name == "Main Cube") { mainCharacter mc = collision.gameObject.GetComponent <mainCharacter>(); if (mc.isPowerful()) { Destroy(this.gameObject); } else { mc.decreaseLives(); } } }