void HandleShoot()
    {
        // spawn all bullets with random direction
        for (int i = 0; i < bulletsPerShot; i++)
        {
            Vector3 shotDirection = GetShotDirectionWithinSpread(weaponMuzzle);

            GameObject Proiectil = PhotonNetwork.Instantiate("Photon Resources/Prefabs/Weapons/Projectile/" + projectilePrefab.gameObject.name, weaponMuzzle.position, Quaternion.LookRotation(shotDirection));

            test = Proiectil.GetComponent <ProjectileStandard_Photon>();
            test.playerWeaponsManager = atribuire;

            // ProjectileBase newProjectile = Instantiate(projectilePrefab, weaponMuzzle.position, Quaternion.LookRotation(shotDirection));

            // newProjectile.ShootPhoton(this);
        }

        // muzzle flash
        if (muzzleFlashPrefab != null)
        {
            GameObject muzzleFlashInstance = Instantiate(muzzleFlashPrefab, weaponMuzzle.position, weaponMuzzle.rotation, weaponMuzzle.transform);
            Destroy(muzzleFlashInstance, 2f);
        }

        m_LastTimeShot = Time.time;

        // play shoot SFX
        if (shootSFX)
        {
            m_ShootAudioSource.PlayOneShot(shootSFX);
        }
    }
Пример #2
0
    void Start()
    {
        projectileSt = GetComponent <ProjectileStandard_Photon>();

        if (!gameObject.GetComponent <PhotonView>().ObservedComponents.Contains(this))
        {
            gameObject.GetComponent <PhotonView>().ObservedComponents.Add(this);
        }

        gameObject.GetComponent <PhotonView>().Synchronization = ViewSynchronization.Unreliable;
        GetValues();
        gameObject.name = gameObject.name + photonView.ViewID;

        //		PhotonNetwork.SendRate = 60;
        //		PhotonNetwork.SerializationRate = 60;
    }