Failure to emit particles

this line of code:

 emissionModule.enabled = isActive;

Keeps giving me this message:

 NullReferenceException: Do not create your own module instances, get them from a ParticleSystem instance UnityEngine.ParticleSystem+EmissionModule.set_enabled (Boolean value)  

Looking through forums I wasn’t able to find a fix for this, but I have seen a lot of people having the same problem :weary:

I’m suspecting that earlier in your code you have something like:

ParticleSystem.EmissionModule emissionModule = new ParticleSystem.EmissionModule();

I.e. an attempt to “create” a “new” instance.

Instead you are expected to obtain a reference to an existing module, like:

ParticleSystem.EmissionModule emissionModule = GetComponent<ParticleSystem>().emission;

Then calls to emissionModule.enabled = isActive; should not have this error.

1 Like

Thanks for the suggestion. I got it now, my problem is that I had Guns on the ship the Particle systems were attached to so when it came time to put the Particle system guns in the serialized field I put the gameobject guns there instead. It worked When we were just activating the whole group, but not when it came time to access the particle system. :sweat_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms