Ejemplo n.º 1
0
        DamageTaker damageTaker2;                   //This helps me call the Health variable found in DamageTaker

        void Start()
        {
            if (ThingTakingDamage2 != null)                                     //if the things that take damage(player/enemy) are not null, then it gets the component so i can call the health variable and display it
            {
                damageTaker2 = ThingTakingDamage2.GetComponent <DamageTaker>(); //gets a link to damage taker script
            }
        }
Ejemplo n.º 2
0
        void OnTriggerEnter(Collider collider)//collision!
        {
            if (collider.transform == bulletShooter)
            {
                return;
            }

            DamageTaker dt = collider.GetComponent <DamageTaker>();

            if (dt != null)
            {
                dt.TakeDamage(damageAmount); // hurt the thing we hit
                Destroy(gameObject);         // remove bullet when it hits something
                return;
            }


            /// do other things?
        }