Example #1
0
    void Shoot()
    {
        flashGun.Play();
        audioS.Play();
        RaycastHit hit;

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range, 9))
        {
            Target           target  = hit.transform.GetComponent <Target>();
            Bicho_ADistancia target2 = hit.transform.GetComponent <Bicho_ADistancia>();
            Bicho_Reina      target3 = hit.transform.GetComponent <Bicho_Reina>();
            MiniSpider       target4 = hit.transform.GetComponent <MiniSpider>();
            if (target != null)
            {
                target.TakeDamge(damage);
            }
            if (target2 != null)
            {
                target2.TakeDamge(damage);
            }
            if (target3 != null)
            {
                target3.TakeDamge(damage);
            }
            if (target4 != null)
            {
                target4.TakeDamage(damage);
            }
            GameObject impactGO = Instantiate(ImpactEffect, hit.point, Quaternion.LookRotation(hit.normal));
            Destroy(impactGO, 0.5f);
        }
    }