All I’m trying to do is enable a gosh darn particle emitter through a function, and the error it’s giving me is;
MissingReferenceException: The variable smoke of ‘alienTeleporter’ doesn’t exist anymore.
You probably need to reassign the smoke variable of the ‘alienTeleporter’ script in the inspector.
alienTeleporter.Landing ()
Now this is telling me that there is no smoke attached to the variable through the inspector. But I’m looking right at it, and yes, a particle emitter is attached to the variable “smoke”.
Code looks like this;
#pragma strict
import SmoothMoves;
var health: int = 10;
var blastPower: int = 5;
var smoke: GameObject;
var landing: AudioClip;
var hover: AudioClip;
var armsFold: AudioClip;
var doorsOpen: AudioClip;
var myAnimation: SmoothMoves.BoneAnimation;
private var soundRate : float = 0.0; // variable to hold sound rate
private var soundDelay : float = 0.0;
private var isIdle : boolean = false;
function Start ()
{
myAnimation.RegisterUserTriggerDelegate(Landing);
animation.Play("Land");
yield WaitForSeconds (6.20);
isIdle = true;
}
function Update ()
{
if (isIdle)
{
animation.Play("Idle");
}
if ( health <= 0 )
{
// stop spawner
// print "level complete or some bullshit"
// play win music
// tally up reward for winning level
// showcase any new item found
// go to next level
Destroy (gameObject);
}
}
function OnTriggerEnter ( other : Collider )
{
if ( other.gameObject.tag == "pigLauncher" )
{
Destroy (gameObject);
}
if ( other.gameObject.tag == "blastRange" )
{
health -= blastPower;
}
}
function Landing ()
{
smoke.particleEmitter.enabled = true;
PlaySound (landing, 0);
}
function PlaySound (soundName : AudioClip, soundDelay : float) // calls to play sound based on sound file name attached to object
{
if ( !audio.isPlaying && Time.time > soundRate ) // sets sound rate
{
soundRate = Time.time + soundDelay; // option to add a delay to the sound before it starts playing
audio.clip = soundName;
audio.Play ();
}
}
thanks in advance, for any insight you may provide.
I've tried changing the smoke variable from a GameObject; to a ParticleEmitter;, with the same results. If I change it to ParticleSystem; it won't let me assign a particle system to it through the inspector...lol.
– Rick74I think ParticleEmitter is not part of ParticleSystem. Former is legacy, latter is Shuriken. In shuriken you must 'Play' the system, not enable it.
– meat5000Hey thanks for the heads up. What exactly do I change that line too then? I tried smoke. particleSystem.Play = true; as well as smoke.particleEmitter.Play = true; both cough out errors. And do I leave the variable as a GameObject, or do I change that to something else? ParticleEmitter; , maybe?
– Rick74Its Play(); Added an answer with some script for you to dissect. :)
– meat5000