// } void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "PlayerProjectile") { //get script info from other PlayerProjectile playerProjectile = other.gameObject.GetComponent <PlayerProjectile>(); ProjectileEffect(playerProjectile.damage); } if (other.gameObject.tag == "PlayerSuperBomb") { //get script info from other PlayerSuperBomb playerProjectile = other.gameObject.GetComponent <PlayerSuperBomb>(); ProjectileEffect(playerProjectile.damage); } }
void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Player") { Debug.Log("collder with player"); DamageEffect(npc.health); } if (other.gameObject.tag == "Obstacle") { //get script info from other Obstacle projectile = other.gameObject.GetComponent <Obstacle>(); if (projectile != null) { DamageEffect(projectile.damage); } } if (other.gameObject.tag == "PlayerProjectile") { Debug.Log("detected player bullet" + other.gameObject.tag + " -- " + other.gameObject.transform.name); //get script info from other PlayerProjectile playerProjectile = other.gameObject.GetComponent <PlayerProjectile>(); // if (playerProjectile = null) Debug.Log("damage not found"); DamageEffect(playerProjectile.damage); } if (other.gameObject.tag == "PlayerSuperBomb") { //get script info from other PlayerSuperBomb playerProjectile = other.gameObject.GetComponent <PlayerSuperBomb>(); DamageEffect(playerProjectile.damage); } // else Debug.Log("unkown object collision: " + other.gameObject.tag + " -- " + other.gameObject.transform.name); }
void OnTriggerEnter(Collider other) { if (other.tag == "PlayerProjectile") { GetComponent <AudioSource>().PlayOneShot(GetComponent <AudioSource>().clip); //get script info from other PlayerProjectile playerProjectile = other.GetComponent <PlayerProjectile>(); //subtract other's projectile damage from health health = health - playerProjectile.damage; if (health <= 0f) { if (rNum == 1) { Instantiate(dropOnDeath1, transform.position, transform.rotation); } else if (rNum == 2) { Instantiate(dropOnDeath2, transform.position, transform.rotation); } else if (rNum == 3) { Instantiate(dropOnDeath3, transform.position, transform.rotation); } Instantiate(deathAnimation, transform.position, transform.rotation); Instantiate(deathSound, transform.position, transform.rotation); //Destroy(transform.gameObject); gameController.GameOver(); Application.LoadLevel("GameOver"); // gameController.AddScore(scoreValue); Destroy(other.gameObject); Destroy(gameObject); } } if (other.tag == "PlayerSuperBomb") { //get script info from other PlayerSuperBomb playerProjectile = other.GetComponent <PlayerSuperBomb>(); //subtract other's projectile damage from health health = health - playerProjectile.damage; if (health <= 0f) { if (rNum == 1) { Instantiate(dropOnDeath1, transform.position, transform.rotation); } else if (rNum == 2) { Instantiate(dropOnDeath2, transform.position, transform.rotation); } else if (rNum == 3) { Instantiate(dropOnDeath3, transform.position, transform.rotation); } Instantiate(deathAnimation, transform.position, transform.rotation); // Destroy(transform.gameObject); gameController.GameOver(); Application.LoadLevel("GameOver"); // gameController.AddScore(scoreValue); Destroy(other.gameObject); Destroy(gameObject); } } }
void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "PlayerProjectile") { GetComponent <AudioSource>().PlayOneShot(GetComponent <AudioSource>().clip); //get script info from other PlayerProjectile playerProjectile = other.gameObject.GetComponent <PlayerProjectile>(); //subtract other's projectile damage from health health = health - playerProjectile.damage; if (health <= 0f) { if (rNum == 1) { Instantiate(dropOnDeath1, transform.position, transform.rotation); } else if (rNum == 2) { Instantiate(dropOnDeath2, transform.position, transform.rotation); } else if (rNum == 3) { Instantiate(dropOnDeath3, transform.position, transform.rotation); } Instantiate(deathAnimation, transform.position, transform.rotation); Instantiate(deathSound, transform.position, transform.rotation); Destroy(transform.gameObject); } } if (other.gameObject.tag == "PlayerSuperBomb") { //get script info from other PlayerSuperBomb playerProjectile = other.gameObject.GetComponent <PlayerSuperBomb>(); //subtract other's projectile damage from health health = health - playerProjectile.damage; if (health <= 0f) { if (rNum == 1) { Instantiate(dropOnDeath1, transform.position, transform.rotation); } else if (rNum == 2) { Instantiate(dropOnDeath2, transform.position, transform.rotation); } else if (rNum == 3) { Instantiate(dropOnDeath3, transform.position, transform.rotation); } Instantiate(deathAnimation, transform.position, transform.rotation); Destroy(transform.gameObject); } } }