- Home /
What am I missing? I already have the semicolon at the end..
var target : Transform; //the enemy's target
var moveSpeed = 3; //move speed
var rotationSpeed = 3; //speed of turning
var gravity: float = 20;
var myTransform : Transform; //current transform data of this enemy
function Awake()
{
myTransform = transform; //cache transform data for easy access/preformance
var inFront : float = 10.0f;
if(!Physics.Raycast(myTransform.position, myTransform.forward, inFront)){
transform.Translate(Vector3.forward*currentMoveSpeed*Time.deltaTime);
}
}
function Start()
{
target = GameObject.FindWithTag("Player").transform; //target the player
}
function Update () {
//rotate to look at the player
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
//move towards the player
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
Error message: "Assets/Enemy.js(21,6): UCE0001: ';' expected. Insert a semicolon at the end."
Answer by Graham-Dunnett · Nov 12, 2012 at 04:41 PM
This line:
float inFront = 10.0f;
is not valid Javascript. Use
var inFront : float = 10.0f;
instead. Note that if you double-click the error at the bottom of the Unity window you'll start MonoDevelop and get taken to the line with the problem. In the error message you get, the (21,6) say that the problem is on line 21 of your code.
ooh thanks man! but now I got a new error! :S "Assets/Enemy.js(25,37): BCE0005: $$anonymous$$ identifier: 'current$$anonymous$$oveSpeed'."
Yeah, but you don't have this variable (current$$anonymous$$oveSpeed) declared in your code. You should declare it! ;D
Thanks a million mate! That fixed it, I really appreciate the fast answer! And as you might already have noticed, I am pretty new to Unity and program$$anonymous$$g so its really nice that there are people in this community that are willing to help! :D