For some reason it just doesn’t work. I know unity has had issues with this for a while. Checking via Debug.Log and isPlaying, it says False.
Here is the part of the code relevant to it:
// References
public Animator animator;
[SerializeField] Transform targetEnemy;
[SerializeField] ParticleSystem weaponVFX;
[SerializeField] AudioClip gunShotSound;
[SerializeField] AudioClip reloadSound;
[SerializeField] AudioClip emptySound;
AudioSource audioSource;
Transform shootingPoint;
[SerializeField] GameObject equippedWeapon;
public void EquippedWeaponType(Item item) // We set the weapon type here based on what the player has equipped
{
if (item is Weapon weapon)
{
switch (weapon.type)
{
// We set the weapon stats based on the weapon type
case Weapon.WeaponType.Handgun:
case Weapon.WeaponType.Shotgun:
case Weapon.WeaponType.Rifle:
weaponDamage = weapon.weaponDamage;
ammoCapacity = weapon.ammoCapacity;
reloadSpeed = weapon.reloadSpeed;
fireRate = weapon.fireRate;
equippedWeaponType = weapon.type;
weaponVFX = weapon.weaponVFX;
weaponVFX.Stop();
equippedWeapon = weapon.model;
shootingPoint = equippedWeapon.transform.Find("Shooting Point");
gunShotSound = weapon.gunShotSound;
reloadSound = weapon.reloadSound;
emptySound = weapon.emptySound;
isEquipped = true;
canShoot = true;
Debug.Log(shootingPoint);
break;
}
}
}
IEnumerator HandgunShooting()
{
var inventoryUI = InventoryUI.instance;
var audioManager = AudioManager.instance;
canShoot = false;
DealDamage();
handgunMagazine --;
animator.SetTrigger("Shoot");
audioSource.PlayOneShot(gunShotSound);
weaponVFX.Play();
Debug.Log(weaponVFX.isPlaying);
//weaponVFX.gameObject.SetActive(true);
inventoryUI.UpdateUI();
yield return new WaitForSeconds(fireRate);
animator.ResetTrigger("Shoot");
weaponVFX.Stop();
//weaponVFX.gameObject.SetActive(false);
canShoot = true;
}