コード例 #1
0
ファイル: Gun.cs プロジェクト: RiskyChristina/Hallway
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            Shoot();
            audioManager.PlaySound("fireSound");
        }

        void Shoot()
        {
            RaycastHit hit;

            if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
            {
                Gravity_One target = hit.transform.GetComponent <Gravity_One>();
                if (target != null)
                {
                    target.TakeDamage(damage);
                }
            }
        }
    }
コード例 #2
0
ファイル: Gun.cs プロジェクト: jehouha/Hallway
    void Update()
    {
        if (Input.GetButtonDown("Fire1") && Time.time > nextFire)
        {
            nextFire = Time.time + fireRate;
            Shoot();
        }

        void Shoot()
        {
            RaycastHit hit;

            if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
            {
                Gravity_One target = hit.transform.GetComponent <Gravity_One>();
                if (target != null)
                {
                    target.TakeDamage(damage);
                }
            }
        }
    }