Null Ref, Do not create your own module instances

Hey all, working on a game based on the Unity microgame the FPS shooter. Running in to a small issue that sort of just popped up and I’m not sure when it happened or how to fix it. If anyone knows how I would fix this it would be great!

Error:
NullReferenceException: Do not create your own module instances, get them from a ParticleSystem instance
UnityEngine.ParticleSystem+EmissionModule.set_rateOverTimeMultiplier (System.Single value) (at <7137a609105f472a9773b5a9b6df383f>:0)
OverheatBehavior.Awake () (at Assets/FPS/Scripts/OverheatBehavior.cs:49)
UnityEngine.Object:Instantiate(GameObject, Transform)

the code at the line mentioned:

void Awake()
    {
        var emissionModule = steamVFX.emission;
        emissionModule.rateOverTimeMultiplier = 0f;

I’m not really sure what to do to fix this. I’ve looked around online but can’t seem to get a solid answer on the problem. Any help would be great!

It’s possible the ParticleSystem itself hasn’t had its Awake() call yet.

Generally do things with this script in Awake(), do things with other objects in Start().

Try renaming Awake to Start. This may have other implications. Here is more intel:

Here is some timing diagram help:

I finally found it, I actually had to check the error while thegame was running, which is why I was having trouble finding it. There was a particle system field that was empty that I didn’t notice. Its always the simple stuff…

1 Like