Question by
Wesley21spelde · Jan 24, 2021 at 03:10 PM ·
networkingexportbulletclientcounter
shooting gun ammo counter not working in export (Photon)
hey guys a weird problem when i test this in the engine it works. but when i export it and play it and shoot my gun my ammo left goes from 30 to 0 in 1or 2 seconds while in the engine game mode it counts the bullets of ammo left.. here is the script
void Update()
{
if (thisGunOnPlayer.active == true)
{
if (AmmoLeftText != null)
{
AmmoLeftText.text = AmmoLeft.ToString();
AmmoClipsLeftText.text = clipsLeft.ToString();
}
if (clipsLeft <= 0)
{
AmmoLeftText.text = 0.ToString();
return;
}
if (isReloading)
{
isFire = false;
return;
}
if (AmmoLeft <= 0)
{
Debug.Log("AmmoLeft = 0....");
isFire = false;
muzzleFlash.SetActive(false);
anim.SetBool("isFiring_Gun", false);
if (clipsLeft <= 0)
{
return;
}
else
{
StartCoroutine(Reload());
}
return;
}
if (Input.GetMouseButton(0))
{
// Player wants to shoot...so. Shoot.
Fire();
if(isReloading == false)
{
isFire = true;
if (isFire == true)
{
anim.SetBool("isFiring_Gun", true);
}
}
if(isReloading == true)
{
isFire = false;
if (isFire == false)
{
anim.SetBool("isFiring_Gun", false);
}
}
}
if (Input.GetMouseButtonUp(0))
{
muzzleFlash.SetActive(false);
isFire = false;
anim.SetBool("isFiring_Gun", false);
}
cooldown -= Time.deltaTime;
}
}
IEnumerator Reload()
{
isReloading = true;
clipsLeft--;
isFire = false;
anim.SetBool("isFiring_Gun", false);
muzzleFlash.SetActive(false);
audioSource.PlayOneShot(ReloadSoundFx, 0.7f);
// Anima.SetBool("Reloading",true)
Debug.Log("Reloading....");
yield return new WaitForSeconds(reloadTime - .25f);
// Anima.SetBool("Reloading",false)
yield return new WaitForSeconds(.25f);
AmmoLeft = (int)maxAmmo;
isReloading = false;
}
Comment
Your answer
Follow this Question
Related Questions
Bullet has wrong direction on client 0 Answers
Can't sync previous connected clients' color. 0 Answers
How can i Spawn a different prefab for client? 0 Answers
MLAPI Client Character Spawning Problem 0 Answers
Unity UNet Correct Usage, Unity 5.4 Beta 0 Answers