コード例 #1
0
    void OnCollisionEnter(Collision collission)
    {
        if (collission.gameObject.tag == "Enemy")
        {
            soundManager.zombieHit = true;
            soundManager.ZombieHit();
            Destroy(gameObject);
            ContactPoint contact = collission.contacts[0];
            Quaternion   rot     = Quaternion.FromToRotation(Vector3.up, contact.normal);
            Vector3      pos     = contact.point;
            Instantiate(BloodEffect, pos, rot);

            collission.gameObject.GetComponent <EnemyHealthManager>().HurtEnemy(damageToGive);
        }

        if (collission.gameObject.tag == "Scenery")
        {
            ContactPoint contact = collission.contacts[0];
            Quaternion   rot     = Quaternion.FromToRotation(Vector3.up, contact.normal);
            Vector3      pos     = contact.point;
            Instantiate(WallHit, pos, rot);
        }
    }