I’m changing my c# scripts into JS, but getting some errors.
var target : GameObject;
var attackTimer;
var coolDown : float;
// Use this for initialization
function Start () {
attackTimer = 0;
coolDown =1.2f;
}
// Update is called once per frame
function Update () {
if(attackTimer > 0)
attackTimer -= Time.deltaTime;
if(attackTimer < 0)
attackTimer = 0;
if(Input.GetKeyUp(KeyCode.F)) {
if(attackTimer == 0){
Attack();
attackTimer = coolDown;
}
}
}
private function Attack(){
var distance = Vector3.Distance(target.transform.position, transform.position);
Vector3 dir = (target.transform.position - transform.position).normalized;
var direction = Vector3.Dot(dir, transform.forward);
Debug.Log(direction);
if(distance < 4) {
if(direction > 0){
//ATTACK CODE HERE
}
}
}
But i’m getting this error Assets/PlayerAttack1.js(32,24): UCE0001: ‘;’ expected. Insert a semicolon at the end.