- Home /
Particle System Using Code
Hey everyone, I have a problem integrating an effect to my game scene. The game has a tank which shoots out a plasma weapon and I'm have a muzzle flash effect, projectile and impact effect.
What I did was to create a variable in the shooting control script and attached a game object with my particle inside. Then in script when I shot the bullet I just did a Muzzle.Play(); to play the particle effect. All I want to do is to play the effect (it's one second long) when I shoot and turn it off right after. (Same for impact effect)
However when I run the scene I don't see anything coming out of the barrel of the tank and I instead get this error: UpdateParticle system should not happen on disabled GO
I've tried Googling the error and did not find anything to help my situation. I might be using the particle system wrong because this is my first time using it and I hope that anyone can help me.
This is the parts of the script that involves the effect:
public ParticleSystem Muzzle; //Attach the particle here
void Shoot() {
//AIBaseTankMovement TankWeaponPos = Bullet.GetComponent();
if(IsShooting == true){
Temp = Shootpoint.transform.position; //Storing starting position
GameObject Bullet1 = Instantiate(Bullet, Temp, transform.rotation) as GameObject;
//Muzzle.enableEmission = true;
Muzzle.Play();
}
}
I do not see anything when I play the scene and the particle does work on its own when I drag it into the current game scene.