private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { tankMovement tank = other.gameObject.GetComponent <tankMovement>(); tank.IncreaseSpeed(speedIncrease); Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { GameObject playerLife = other.gameObject; tankMovement tankhealth = playerLife.GetComponent <tankMovement>(); tankhealth.health -= 1; Destroy(GameObject.FindGameObjectWithTag("PlayerLife")); Destroy(gameObject); } else if (other.tag == "Base") { GameObject playerBase = other.gameObject; BaseHealth baseHealth = playerBase.GetComponent <BaseHealth>(); baseHealth.health -= 1; Destroy(gameObject); } }