- Home /
Scripting error: ';' expected. Insert a semicolon at the end.
This is my script that is getting the error message:
function (lightFire) { var campfire : GameObject = GameObject.Find ("campfire") ; var campSound : AudioSource = campfire.GetComponent (AudioSource) ; campSound.Play () ;
var flames : GameObject = GameObject.Find ("FireSystem") ;
var flameEmitter : ParticleEmitter = flames.GetComponent (ParticleEmitter) ;
flameEmitter.emit = true ;
var smoke : GameObject = GameObject.Find ("SmokeSystem") ;
var smokeEmitter : ParticleEmitter = smoke.GetComponent (ParticleEmitter) ;
smokeEmitter.emit = true ;
Destroy (GameObject.Find ("matchGUI")) ;
}
The last line is the error line. I do not understand what is wrong with my code. There should not be a semi-colon there because it ends the statement, right? I am using the book, "Unity Game Development Essentials", by Will Goldstone, and I typed in the exact same thing that was in the book, but I am still getting the error. Please enlighten me.
Ah thanks I see what I did wrong, I should've seen it, but I must've skipped over it.
Answer by Robindoo · Jan 12, 2011 at 03:16 AM
Your function name might be the problem. The name of the function should be out of the bracket
function lightFire()
yes thanks that was the problem, I should've seen it sooner, but i guess I just skipped right over it.
Answer by Uriel_96 · Jan 12, 2011 at 03:18 AM
sometimes when it says error ";" expected dosen't means that the problem is ";" so what is rong is at put function (lightFire), that totaly rong, the correct form is:
function lightFire(){}
If you want to put to repite this lots of times you may put:
function Update(){
lightFire();
}
function lightFire{}
Wow Unity answers is awesome, you all answered me in 11 $$anonymous$$utes. Thanks, yes that fixed it.
by the way, wrong is spelled with a w, just because you did it twice, but I do appreciate the answer.
sorry I don't speak to well English, I'm not from USA. :P