Particle Emitter error, Missing reference exception.

Hi, I have a this error constantly popping up.

MissingReferenceException: The object of type ‘ParticleEmitter’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.

I have this script on my waterfall, the tag “EditorOnly” is a rock object (with a mesh collider) designed to stop the waterfall from flowing when it conjuction with the waterfalls collider. All the publicemitters are assigned in the inspector. thanks.

using UnityEngine;

using System.Collections;

public class Waterfalltrigger2 : MonoBehaviour {

public ParticleEmitter myBigmist = null;
public ParticleEmitter myEmitter = null;
public ParticleEmitter myWatersplash = null;
public Light Waterpointlight = null;

void OnTriggerEnter(Collider other){ if(other.CompareTag(“EditorOnly”)) myEmitter.emit = false ; myWatersplash.emit = false ; myBigmist.emit = false ; Waterpointlight.intensity = 0 ; }

void OnTriggerExit(Collider other){ if(other.CompareTag(“EditorOnly”)) myEmitter.emit = true ; myWatersplash.emit = true ; myBigmist.emit = true ; Waterpointlight.intensity = 2 ; } }

I would try hijinxbassist’s suggestion.

If that doesn’t work, make sure that you’ve set the references up in the inspector. If any of them are listed as “None”, they’re not pointing at anything.

Finally, you might want to check if the ParticleEmitter has AutoDestruct set – if so, it will self-destroy once the emitter has finished. After that happens, subsequent attempts to access to emitter can produce errors.

If push comes to shove, you could always check for null before using the reference. It might allow you to figure out exactly when things are going wrong, if you log a message once that happens.