void Start() { healthBar = healthBarImage.GetComponent <Image>(); TargetObj = target.transform.gameObject; countT = 1; //Plane_B_script = GameObject.Find("Plane").GetComponent<Plane_Brain>(); Plane_B_script = plane.GetComponent <Plane_Brain>(); Base_script = TargetObj.GetComponent <BDefender>(); }
//USING BULLETS /* * public void TurretDamage(double ammount, ref bool death) * { * health -= ammount; * if (health < 1) * { * Destroy(this); * //Instantiate(explosion, transform.position, transform.rotation); * Destroy(gameObject); * death = true; * } * //Debug.Log("Damage Applied!"); * }*/ void OnCollisionStay(Collision col) { if (col.gameObject.tag == "Defender") { //CALL DAMAGE TURRET FUNCTION BDefender _hitDamage = col.gameObject.GetComponent <BDefender>(); health -= _hitDamage.DPSO; //set damage to 100 and health to 100 if (health < 1) { //Instantiate(explosion, transform.position, transform.rotation); Destroy(this); Destroy(gameObject); } } }
void OnCollisionEnter(Collision col) { if (col.gameObject.tag == "Defender") { Debug.Log("BASE COLIDE !!!!!!!"); damageSound.Play(); Base_script.AttackerDMG(DPSO); BDefender _hitDamage = target.GetComponent <BDefender>(); health -= _hitDamage.DPSO; if (health < 1) { //Plane_B_script.KillCountUp(); no need since base kills dont count Destroy(this); Destroy(gameObject); } } }