void OnTriggerEnter2D(Collider2D other) // Jeżeli wejdziemy w obiek bohaterem to się usunie { if (other.gameObject.name == "Player") { Destroy(this.gameObject); AudioSource.PlayClipAtPoint(clip, transform.position); counterController.IncrementCounter(); // Wywołanie metody do dodania punktów } }
// Update is called once per frame void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.name == "Hero") { Destroy(this.gameObject); AudioSource.PlayClipAtPoint(clip, transform.position); counterController.IncrementCounter(); } }
void OnTriggerEnter2D(Collider2D other) //funkcja zwróci nam jaki obiekt skolidował z obiektem, który będzie miał przypięty ten skrypt { if (other.gameObject.name == "Dron") // jeśli koliduje z dronem to... { Destroy(this.gameObject); //zmień jego pozycje na startPoint counterController.IncrementCounter(); AudioSource.PlayClipAtPoint(clip, transform.position); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.name.Equals("Cat")) { Destroy(this.gameObject); AudioSource.PlayClipAtPoint(AudioClip, transform.position); Destroy(cristalLight); _counterController.IncrementCounter(); Instantiate(particlesPrefab, transform.position, transform.rotation); } }