// Start is called before the first frame update private void OnTriggerEnter(Collider col) { if (col.tag == "Player") { GameObject controlador = GameObject.Find("controladorPlacar"); scriptPlacar script = controlador.GetComponent <scriptPlacar>(); script.atualizar(1); Destroy(this.gameObject); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag != "Player") { GameObject gamePlacar = GameObject.Find("controlePlacar"); scriptPlacar script = gamePlacar.GetComponent <scriptPlacar>(); script.incrementar(1); } Destroy(collision.gameObject); Destroy(gameObject); }