Semicolon Error... have all semicolons at the ends

hi there,
i know there are some threads about this but i cant find the help i need in these.
hope you can fix my problem. :slight_smile:
in my script i get always the " β€˜;’ expected. Insert a semicolon at the end." Error but the line is (14,14)

32170-hilfe.jpg

2 Answers

2

You have a mixture of UnityScript and C# syntax. Assuming this is a UnityScript, line14 should be:

var myColor : Color = new Color(0,0,1,1);

this error is now gone but another appears. "unexpected token: myColor." [32177-hilfe.jpg|32177]

–

Replace your myColor line with the following; var myColor : Color; myColor = Color(0.2F, 0.3F, 0.4F); Or simply copy my the code from my comment down below.

–

@-teze - updated - I missed off the "var" :)

–

thank you all :)

–

This should help you:

#pragma strict

function OnCollisionEnter (col : Collision) {
	
	if(col.gameObject.name == "Boden"){
	ColorTest();
	}

}

function ColorTest () {

	var myColor : Color;
    myColor = Color(0.2F, 0.3F, 0.4F);
	if(this.gameObject.renderer.material.color == myColor){
	Destroy(gameObject);
	}
}