コード例 #1
0
ファイル: Gun.cs プロジェクト: Sazails/Unity-3D
    void Shoot()
    {
        //fireSound.Play ();
        //muzzleFlash.Play ();

        currentAmmo--;

        anim.Play("Shoot");


        RaycastHit hit;

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

            EnemyHealth target = hit.transform.GetComponent <EnemyHealth> ();
            if (target != null)
            {
                thePoints.AddMoney(coinValue);
                target.TakeDamage(Random.Range(lowestDamage, highestDamage));
            }

            if (hit.rigidbody != null)
            {
                hit.rigidbody.AddForce(-hit.normal * impactForce);
            }

            //GameObject impactGO = Instantiate (impactEffect, hit.point, Quaternion.LookRotation (hit.normal));
            //Destroy (impactGO, 2f);
        }
    }