So i am trying to create code where by when I shoot, bullets will shoot out of my gun at the same time, from 3 different positions. If I do a singular instantiate, it works fine, like below:
IEnumerator ShotgunCoolDown()
{
PistolGunEffect.SetActive(false);
canShoot = true;
yield return new WaitForSeconds(0.45f);
GetComponent<AudioSource>().PlayOneShot(PistolGunSound);
canShoot = false;
StartCoroutine(COPlayOneShot("Fire"));
RifleGunEffect.GetComponent<ParticleSystem>().Play();
(Instantiate(PistolBullet, ShotgunPoint.transform.position, transform.root.rotation) as GameObject).GetComponent<BulletScript>().Activate();
yield return new WaitForSeconds(0.25f);
}
However if i add multiple instantiates with different positionings, it will spawn the bullet for a millisecond before disappearing:
IEnumerator ShotgunCoolDown()
{
PistolGunEffect.SetActive(false);
canShoot = true;
yield return new WaitForSeconds(0.45f);
GetComponent<AudioSource>().PlayOneShot(PistolGunSound);
canShoot = false;
StartCoroutine(COPlayOneShot("Fire"));
RifleGunEffect.GetComponent<ParticleSystem>().Play();
(Instantiate(PistolBullet, ShotgunPoint.transform.position, transform.root.rotation) as GameObject).GetComponent<BulletScript>().Activate();
(Instantiate(PistolBullet, ShotgunPoint1.transform.position, transform.root.rotation) as GameObject).GetComponent<BulletScript>().Activate();
(Instantiate(PistolBullet, ShotgunPoint2.transform.position, transform.root.rotation) as GameObject).GetComponent<BulletScript>().Activate();
yield return new WaitForSeconds(0.25f);
}
Any ideas how to address this?