void Shoot()
    {
        muzzleFlash.Play();

        currentAmmo--;

        RaycastHit hit;

        if (Physics.Raycast(head.transform.position, head.transform.forward, out hit, range))
        {
            Debug.Log(hit.transform.name);

            EnemyControler target  = hit.transform.GetComponent <EnemyControler>();
            BossControler  target2 = hit.transform.GetComponent <BossControler>();

            if (target != null)
            {
                target.TakeDamageEnemy(damage);
            }

            else
            {
                target2.TakeDamageEnemy(damageB);
            }

            GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
            Destroy(impactGO, 0.5f);
        }
    }
Ejemplo n.º 2
0
 private void Awake()
 {
     instance = this;
 }