コード例 #1
0
    //collides with player's controller == decrease health

    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Axe"))
        {
            life -= 2;

            // Place sound here

            // cut affect
            GameObject Blood = Instantiate(BloodSpray, this.gameObject.transform.position, Quaternion.identity);
            Blood.transform.parent = this.gameObject.transform; // make blood effect child of animal object

            Destroy(Blood, 2f);

            // play alien gets hit sound
            noise.AlienHitSound();

            if (life == 0)
            {
                ItemCation = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y + 0.5f, this.gameObject.transform.position.z);

                Creature = this.gameObject;

                Destroy(Creature, 2f);

                // Alien Die Sounds
                noise.AlienDiesSound();

                Destroy(GetComponent <SphereCollider>());

                GameObject Wing = Instantiate(DropItemPrefab, ItemCation, Quaternion.identity);

                GameObject Explosion = Instantiate(ExplosionPrefab, ItemCation, Quaternion.identity);
                // play sound for instantiating
            }
        }
    }