- Home /
Insert a semicolon error
So I hate to post another one of these "missing ;" to this site, but i'm going a little mad staring at my code at the moment. I'd imagine that my Syntax is of on, but i can't find it.
var star : ParticleEmitter;
function OnCollisionEnter(theCollision : Collision) { if(theCollision.gameObject.name == "bullet(Clone)") { Instantiate(star, transform.position, transform.rotation); Destroy(gameObject); } }
function Start() { var i : int = 0;
for(i = 0;i==2;i++) { i=2 Destroy(GameObject); } }
The error is being thrown on the "i=2" line. Thanks in Advance And for some reason the code snippet tool isn't spacing my code right, so i added a blank line myself, sorry if it makes it harder to see, but it looks better than bunched into 3 lines
D
here isn't anything in your Start function that even begins to make sense. Please create a new version with comments, telling us what you believe the code SHOULD be doing.
Answer by Robindoo · Jan 26, 2011 at 03:51 AM
It might be something wrong with your for loop. It should go something like this
for(i = 0; i <= 2; i++)
{
if(i == 2)
{
Destroy(GameObject);
}
}
thanks, i knew it didn't look right, anyway now i just need to figure out how to add to "i" on a collision
Destroy(GameObject) was a big part of the problem. That's suggesting you can destroy the class, GameObject, which is impossible. You most likely want "gameObject". There's no reason to have it in that loop, regardless; just put it afterwards. I do hope you at least have more code in that loop.
what i am doing is making an enemy take 2 hits and then blow up, so yes i do have more script in the loop, and now it is in a collision function. I have no clue what i was thinking with the syntax of my loop though...
Your answer
Follow this Question
Related Questions
Scripting error: ';' expected. Insert a semicolon at the end. 2 Answers
doing force and spin on a gameobject when clicking on plane. 2 Answers
UCE0001: ';' expected. Insert a semicolon at the end. 2 Answers
Using JavaScript and C# inside one script 2 Answers
help with UCE0001: ';' expected. Insert a semicolon at the end 3 Answers