예제 #1
0
    // code to shoot gun
    void Shoot()
    {// makes gun go  S H O O T
        muzzleFlash.Play();
        //  shoots wherever ur looking at
        RaycastHit hit;

        if (Physics.Raycast(fpscam.transform.position, fpscam.transform.forward, out hit, range))
        {// shows in console the fire
            Debug.Log(hit.transform.name);
            // checks if the target took damage or not
            notuseing Target = hit.transform.GetComponent <notuseing>();
            if (Target != null)
            {// makes target take damage
                Target.Takedamage(damage);
            }
            // code for praticle to show every time u click
            GameObject impactGO = Instantiate(impacteffect, hit.point, Quaternion.LookRotation(hit.normal));
            // destorys  praticles that despawned so it doesnt lag the game
            Destroy(impactGO, 1f);
        }
    }
예제 #2
0
    // code to shoot gun
    void Shoot()
    {
        //  Vector3 explosionpos = equip.transform.position;
        //  Collider[] colliders = Physics.OverlapSphere(explosionpos, radius);
        //  foreach (Collider HIT in colliders)
        currentammo--;
        // makes gun go  S H O O T
        muzzleFlash.Play();
        //  shoots wherever ur looking at
        RaycastHit hit;

        if (Physics.Raycast(fpscam.transform.position, fpscam.transform.forward, out hit, range))
        {// shows in console the fire
            Debug.Log(hit.transform.name);

            Target target = hit.transform.GetComponent <Target>();
            if (target != null)
            {
                target.takedamage(damage);
            }


            // checks if the target took damage or not
            notuseing Target = hit.transform.GetComponent <notuseing>();
            if (Target != null)
            {// makes target take damage
                Target.Takedamage(damage);
            }



            // code for praticle to show every time u click
            GameObject impactGO = Instantiate(impacteffect, hit.point, Quaternion.LookRotation(hit.normal));
            // destorys  praticles that despawned so it doesnt lag the game
            Destroy(impactGO, 3f);
        }
    }