Beispiel #1
0
    private void RpcHitReaction(NetworkInstanceId netId, Vector3 point, Vector3 normal)
    {
        GameObject hit = ClientScene.FindLocalObject(netId);

        if (hit == null)
        {
            return;
        }

        if (hit.GetComponent <Rigidbody>() != null)
        {
            hit.GetComponent <Rigidbody>().AddForce(fpsCamera.transform.forward * 200f);
        }
        BulletSound bs = hit.GetComponent <BulletSound>();

        if (bs != null)
        {
            bs.Play();
        }
        BulletRandomSound brs = hit.GetComponent <BulletRandomSound>();

        if (brs != null)
        {
            brs.Play();
        }
        MakeImpactFX(point, normal);
        MakeBulletHole(point, normal, hit.transform);
    }
Beispiel #2
0
    public void Shoot()
    {
        MakeShell();
        GetComponent <AudioSource>().Play();
        muzzleFlash.enabled = true;
        Invoke("OffFlashLight", 0.05f);

        RaycastHit hit;

        if (Physics.Raycast(fpsCamera.transform.position, fpsCamera.transform.forward, out hit, 200f, 1 << LayerMask.NameToLayer("Floor")))
        {
            print(hit.transform.name);
            //if(hit.rigidbody != null)
            //{
            //    hit.rigidbody.AddForce(fpsCamera.transform.forward * 500f);
            //}
            BulletSound bs = hit.transform.gameObject.GetComponent <BulletSound>();
            if (bs != null)
            {
                bs.Play();
            }

            BulletRandomSound brs = hit.transform.gameObject.GetComponent <BulletRandomSound>();
            if (brs != null)
            {
                brs.Play();
            }
        }

        GameObject fx = Instantiate(impactFx, hit.point, Quaternion.identity);  // MuzzleEf

        Destroy(fx, 0.2f);

        //MakeBulletHole(hit.point, hit.normal, hit.transform);
        transform.localPosition = originPos - Vector3.forward * 0.3f;
        transform.localPosition = new Vector3(originPos.x, originPos.y, Mathf.Clamp(transform.localPosition.z, originPos.z - 0.3f, originPos.z));
    }
Beispiel #3
0
    void RpcHitReaction(NetworkInstanceId netId, Vector3 point, Vector3 normal, NetworkInstanceId attackerid, Hitpart part)
    {
        GameObject hit      = ClientScene.FindLocalObject(netId);
        GameObject attacker = ClientScene.FindLocalObject(attackerid);

        if (hit != null && attacker != null)
        {
            if (hit.GetComponent <Rigidbody>() != null)
            {
                hit.GetComponent <Rigidbody>().AddForce(fpsCamera.transform.forward * 200f);
            }
            BulletSound bs = hit.GetComponent <BulletSound>();
            if (bs != null)
            {
                bs.Play();
            }
            BulletRandomSound brs = hit.GetComponent <BulletRandomSound>();
            if (brs != null)
            {
                brs.Play();
            }

            Hitreaction hr = hit.GetComponent <Hitreaction>();
            if (hr != null)
            {
                MobController mc = hit.GetComponent <MobController>();
                if (mc != null)
                {
                    mc.attacker = attacker;
                }
                hr.React(part.ToString());
            }

            MakeImpactFX(point, normal);
            MakeBulletHole(point, normal, hit.transform);
        }
    }