private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player1" && _isCoin == true) { // Player1 player = other.GetComponent<Player1>(); _UIManager.UpdateScore(_scoreValue); Destroy(this.gameObject); } else if (other.tag == "Player1" && _isMeteor == true) { Player1 player = other.GetComponent <Player1>(); player.Damaged(); Destroy(this.gameObject); } else if (other.tag == "Player2" && _isMeteor == true) { // Player2 player = other.GetComponent<Player2>(); _UIManager.UpdateScore(_scoreValue); Destroy(this.gameObject); } else if (other.tag == "Player2" && _isCoin == true) { // Player2 player = other.GetComponent<Player2>(); Destroy(this.gameObject); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player1") { Player1 player = other.GetComponent <Player1>(); if (player != null) { player.Damaged(); } } else if (other.tag == "attack") { hasBeenStruck(other.name); Damage(); } }