Unable to enable/disable Particle System emission in script
I'm having issues trying to enable / disable emission from different GameObject in Script. I saw many questions related to mine and the Scripting API and it seems I'm doing it right, still doens't work. Can anyone help pls?
Here is the code (I'm testing, trying to start emissions on start):
....
private ParticleSystem particle;
private ParticleSystem.EmissionModule em;
....
void Start()
{
particle = GameObject.Find("EnemyShootParticleSystem").GetComponent<ParticleSystem>();
em = particle.emission;
em.enabled = true;
}
I also tried a few things with "Play()" and "Stop()" but it doesn't work, the particles don't start emmiting. I don't get it, what's the problem?
Note: the "Emission" checkbox is disabled in GUI, since I want to enable / disable in script. I know the recommended way is not via Script, but I need to do it this way (and if it's possible, it should work).
[1]: /storage/temp/191388-ps-02.png
Answer by Head0nF1re · Jan 18 at 09:47 PM
@privatecontractor Ups, error while copy pasting, question updated now. I assign it to "particle"
Ok, can you upload your emission tab here? Maybe you not settup it? Burst etc?
Sure, just added the photos of the Particle System tab as attachements in the question. I don't know what burst is, I don't really understand much of game dev... But when I have the checkbox "Emission" ticked, the particles are emmited fine
Answer by privatecontractor · Jan 18 at 10:27 PM
Fastes way (hope) atache you Particle System to empty game object... turn check emmision on.... enable play on start... and dissable whole game object... then enable and disable gameobject whe you need ParticleSystem to emmit.... know its terrible but will work (sometties fast solution is good enough)
Yeah, that was my last option in case I couldn't figure out why this isn't working. Guess I will just do that, don't wanna waste much time with this since is just some small work that I have to do... Thanks for help anyway!
Your answer
Follow this Question
Related Questions
Creating Meteor with Physics (where the Particle System Works) 0 Answers
Script not playing Particle Effect 0 Answers
How can I get the game object that a particle trigger detects? 0 Answers
No works vfx tests 0 Answers
Sprite Maske and trails/particles? 1 Answer