private void OnTriggerEnter(Collider other)
 {
     if (carHealth && other.tag == "Bullet")
     {
         carHealth.DamageTaken(20); // damage car if car has health and a bullet hit it
     }
 }
        /// <summary>
        /// When the minion hits a target
        /// </summary>
        /// <param name="collision"></param>
        private void OnTriggerEnter(Collider collision)
        {
            HealthScript healthOfPlayer = collision.GetComponent <HealthScript>();

            if (collision.gameObject.tag == "Player" && healthOfPlayer)
            {
                healthOfPlayer.DamageTaken(15);
            }
        }
예제 #3
0
        /// <summary>
        /// When the projectile hits an object
        /// </summary>
        /// <param name="other"></param>
        private void OnTriggerEnter(Collider other)
        {
            HealthScript healthOfThing = other.GetComponent <HealthScript>();               // gets health script of object

            if (healthOfThing)                                                              // if object has a health script
            {
                healthOfThing.DamageTaken(damageAmt);                                       // damages object
                Instantiate(bulletParticles, this.transform.position, Quaternion.identity); // spawns the particle effect
                Destroy(this.gameObject);                                                   // destroys the projectile
            }
        }
        /// <summary>
        /// When the projectile hits a target
        /// </summary>
        /// <param name="other"></param>
        private void OnTriggerEnter(Collider other)
        {
            HealthScript healthOfThing = other.GetComponent <HealthScript>(); // making a local variable from getting access from HealthScript

            if (healthOfThing)                                                // if the healthOfThing has data/storing something
            {
                healthOfThing.DamageTaken(damageAmt);                         // damages the target
            }

            Destroy(this.gameObject);                                                   // destroys the projectile
            Instantiate(bulletParticles, this.transform.position, Quaternion.identity); // instantiates the bullet particles when it hits an object
        }
예제 #5
0
        private void OnTriggerEnter(Collider other)
        {
            HealthScript healthOfThing = other.GetComponent <HealthScript>();

            if (healthOfThing)
            {
                healthOfThing.DamageTaken(damageAmt);
            }

            Instantiate(bulletParticles, this.transform.position, Quaternion.identity);
            Destroy(this.gameObject);
        }
예제 #6
0
        /// <summary>
        /// When the missile hits the target
        /// </summary>
        /// <param name="other"></param>
        private void OnTriggerEnter(Collider other)
        {
            HealthScript healthOfThing = other.GetComponent <HealthScript>(); // gets the HealthScript

            if (healthOfThing)                                                // if the healthOfThing is 'there'
            {
                healthOfThing.DamageTaken(damageAmt);                         // damages the target
            }

            Instantiate(missleParticles, this.transform.position, Quaternion.identity); // spawns the particle effect of the explosion
            Destroy(this.gameObject);                                                   // Destroys gameObject
        }
예제 #7
0
        void SplashDamageCheck()
        {
            Collider[] enemiesHit = Physics.OverlapSphere(transform.position, 10); // checks to see if enemies in a 10 meter distances were hit

            foreach (Collider other in enemiesHit)
            {
                HealthScript healthOfThing = other.GetComponent <HealthScript>(); // get enemies health
                if (healthOfThing)                                                // if there were enemies that have health
                {
                    healthOfThing.DamageTaken(damageAmt);                         // damages enemies
                }
            }
        }
        /// <summary>
        /// Makes the splash damage work and damage things around it
        /// </summary>
        void SplashDamage()
        {
            Collider[] pawnsHit = Physics.OverlapSphere(transform.position, 7); // things that were hit in list

            foreach (Collider other in pawnsHit)
            {
                HealthScript healthOfThing = other.GetComponent <HealthScript>();
                if (healthOfThing && healthOfThing.health > 0)
                {
                    healthOfThing.DamageTaken(damageAmt); // damage thing
                }
            }
        }