Beispiel #1
0
        // take some damage when a projectile collides with the building
        public void OnCollisionEnter(Collision collision)
        {
            Projectile projectile;

            if ((projectile = collision.gameObject.GetComponent <Projectile>()) != null)
            {
                // take damage. heath will fire an event if the damage is equal to 0
                health.takeDamage(projectile.damageAmount);
                // destroy the projectile
                projectile.destroySelf();
            }
        }