Question by
unity_NZybVjEwLqlH_A · Apr 01, 2019 at 03:32 PM ·
unity 5particle system
Particle system play stop work
Hi! I develop an fps game where I use muzzle flash to my gun with a particle system. But it stops work then the player stops shoot for one to two secounds (then the particle system not playing). It's like the particle system don't want to play. Here is the code:
void Update()
{
if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire)
{
nextTimeToFire = Time.time + 1f/firerate;
Shoot();
}
}
void Shoot()
{
muzzleFlash.Play();
gunSound.Play();
RaycastHit hit;
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
{
Debug.Log(hit.transform.name);
Target target = hit.transform.GetComponent<Target>();
if (target != null)
{
target.TakeDamage(damage);
}
}
}
Comment