/// <summary> /// Sent when another object enters a trigger collider attached to this /// object (2D physics only). /// </summary> /// <param name="other">The other Collider2D involved in this collision.</param> void OnTriggerEnter2D(Collider2D other) { if (other.transform.tag == "Player") { _player.AddScore(); } }
void OnTriggerExit2D(Collider2D other) { Bird bird = other.gameObject.GetComponent <Bird>(); if (bird && !bird.IsDead()) { bird.AddScore(1); } }
private void OnTriggerEnter2D(Collider2D collision) { Bird bird = collision.gameObject.GetComponent <Bird>(); if (bird && !bird.IsDead()) { bird.AddScore(1); } }
void OnTriggerExit2D(Collider2D collision) { Bird bird = collision.gameObject.GetComponent <Bird>(); //get score jika burung tidak null dan burung belum mati; if (bird && !bird.IsDead()) { bird.AddScore(1); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.TryGetComponent(out ScoreZone scoreZone)) { _bird.AddScore(); } else { _bird.Die(); } }
private void OnTriggerExit2D(Collider2D collision) { //Mendapatkan komponen bird Bird bird = collision.gameObject.GetComponent <Bird>(); //Menambahkan score jika burung tidak null dan burung belum mati if (bird && !bird.IsDead()) { bird.AddScore(1); } }
void OnTriggerExit2D(Collider2D collision) { Bird bird = collision.gameObject.GetComponent <Bird>(); if (bird && !bird.getIsDead()) { bird.AddScore(1); if (bird.getScore() % 5 == 0) { randPowerUps(); } } }
void OnTriggerExit2D(Collider2D collision) { // ambil objek bird Bird bird = collision.gameObject.GetComponent <Bird>(); //Menambahkan score jika burung tidak null dan burung belum mati; if (bird && !bird.IsDead()) { bird.AddScore(1); // delete object point kalau sudah collision Destroy(gameObject); } }
void OnTriggerExit2D(Collider2D collision) { //Mendapatkan komponen Bird Bird bird = collision.gameObject.GetComponent <Bird>(); //Menambahkan score jika burung tidak null dan burung belum mati; if (bird && !bird.IsDead()) { bird.AddScore(1); RNG_Ammo = Random.Range(1, 5); if (RNG_Ammo == 1) { shoot.AddAmmo(1); } } }
// Deteksi tabrakan ketika yang nabrak keluar area collider void OnTriggerExit2D(Collider2D collision) { //Mendapatkan komponen Bird Bird bird = collision.gameObject.GetComponent <Bird>(); //Menambahkan score jika Bird tidak null dan Bird belum mati; if (bird && !bird.IsDead()) { bird.AddScore(1); } //Jika Pipe hancur/Destroy dan hilang dari area collider Point, hancur pula object Point Pipe pipe = collision.gameObject.GetComponent <Pipe>(); if (pipe) { Destroy(gameObject); } }