예제 #1
0
    void Attack()
    {
        RaycastHit hit;

        anims.Play();

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

            SimpleAIController target = hit.transform.GetComponent <SimpleAIController>();

            if (target != null)
            {
                sounds[0].Play();
                target.TakeDamage(damage);
            }
            else
            {
                sounds[1].Play();
            }
        }
        else
        {
            sounds[1].Play();
        }

        attackTimer = 0;
    }
예제 #2
0
    void Attack()
    {
        RaycastHit hit;

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

            SimpleAIController target = hit.transform.GetComponent <SimpleAIController>();

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


        attackTimer = 0;
    }
예제 #3
0
파일: Gun.cs 프로젝트: GNeki4/NewSmsbr
    void Shoot()
    {
        muzzleFlash.Play();
        gunshot.Play();
        recoil.Fire();

        RaycastHit hit;

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

            SimpleAIController target = hit.transform.GetComponent <SimpleAIController>();

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

            GameObject impactGo = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));

            Destroy(impactGo, 0.5f);
        }
    }