- Home /
error in code (Please help)
I have a error in my way point script, Two infact (I made one of them accidentily)
The script- #pragma strict
var timer:int = 0;
var player :GameObject ;
var maxRange :int = 0;
function Start () {
}
function Update () {
timer++;
if (timer == 100)
{
timer = 0;
if (gameObject.tag == "waypoint")
{
if (Vector3 .Distance (player .transform.position ,transform.position ) > maxRange )
{
gameObject.tag = "illegal";
}
}
else if (gameObject.tag == "illegal")
{
if (Vector3 .Distance (player .transform.position ,transform.position ) < maxRange )
{
gameObject.tag = "waypoint";
}
}
}
{
}
The errors
-waypoint.js(66,2): UCE0001 ':'expected. Insert a semicolon at the end. -waypoint.js(67,1): BCE0044: expecting }. found".
very simple: you have an extra opening bracket at the end.. Also, this script could be vastly simplified:
function Update(){
if(Vector3.Distance(player.transform.position,transform.position ) < maxRange && gameObject.tag == "illegal")
gameObject.tag = "waypoint";
else if(Vector3.Distance(player.transform.position,transform.position ) > maxRange && gameObject.tag == "waypoint")
gameObject.tag = "illegal";
}
the rest is superfluous (the timer)
Answer by Olgo · Nov 06, 2012 at 07:18 AM
Put a # in front of "pragma strict" in your first line.
Delete the "{" in the second to last line.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Targetting error please help 0 Answers
Block Collision Sliding off 0 Answers
Tons of compiler Errors.. Please help ;_; 1 Answer
BCE0044: expecting EOF, found '}'. 1 Answer