- Home /
Particle System not playing
Debug Console says:
NullReferenceException: Object reference not set to an instance of an object DamCtrl.Update () (at Assets/CarScene/Scripts/DamageScripts/DamCtrl.js:62)
DamCtrl.js (Clipped):
var health : float;
var smoke : ParticleSystem;
function Start () {
smoke = gameObject.GetComponent(ParticleSystem);
}
function Update () {
if(health <= 75 && health >= 55){
smoke.Play();
}
}
Line 62 is "smoke.Play();"
What's missing??
Answer by CodeMasterMike · Feb 06, 2013 at 10:27 AM
Looks like smoke is not valid.
Make sure that the Particle system is really found in your start function before you try to play the effect:
if(smoke != null)
{
smoke.Play();
}
Good luck!
ok, if I add this there is no error in the console... But I still can't get smoke to play :-/
Thats probably because the code doesn't find the smoke effect.
If you run this as well, then you will get a console message if the smoke effect object is not found.
if(smoke == null)
{
Debug.Log("Smoke is not found.");
}
If it is not found, you need to check that you have set the particleeffect in the inspector, or however you set it in your project.
Your answer
Follow this Question
Related Questions
Weird behaiviour with particle system. 1 Answer
How to Pause ParticleSystem on Jump? 2 Answers
ParticleSystem.Play() not working 1 Answer
Particle system Rewinded but not start again 0 Answers
Particle System doesn't want to Play 0 Answers