Hi all,
I am making one tutorial about Unity Scripting Space Shooter by Design3 and the code is the following:
var laser : GameObject;
var maxFireFreq : float;
private var lastShot : float;
var laserType : int ;
private var laserTimer : float ;
function Update () {
if (Input.GetButtonDown(“Fire1”) && (Time.time > lastShot + maxFireFreq) ) {
Fire();
}
laserTimer -= 1 * Time.deltaTime;
if (laserTimer < 0) {
laserType = 0;
}
}
function Fire() {
lastShot = Time.time;
if (laserType == 0) {
Instantiate(laser, transform.position, transform.rotation);
} else if (laserType == 1) {
Instantiate(laser, transform.position, Quaternion.Euler(Vector3(0,-20,0)));
yield WaitForSeconds (0.1);
Instantiate(laser, transform.position, transform.rotation);
yield WaitForSeconds (0.1);
Instantiate(laser, transform.position, Quaternion.Euler(Vector3(0,20,0)));
} else if (laserType == 2) {
Instantiate(laser, transform.position, Quaternion.Euler(Vector3(0,-30,0)));
yield WaitForSeconds (0.1);
Instantiate(laser, transform.position, Quaternion.Euler(Vector3(0,-15,0)));
yield WaitForSeconds (0.1);
Instantiate(laser, transform.position, transform.rotation);
yield WaitForSeconds (0.1);
Instantiate(laser, transform.position, Quaternion.Euler(Vector3(0,15,0)));
yield WaitForSeconds (0.1);
Instantiate(laser, transform.position, Quaternion.Euler(Vector3(0,30,0)));
}
function PowerUpLaser() {
laserType += 1;
laserType = Mathf.Clamp(laserType,0,2);
laserTimer = 3;
}
Now, I got the following errors:
1- Assets/Standard Assets/Scripts/FireScript1.js(40,11): BCE0044: expecting (, found ‘PowerUpLaser’.
2- Assets/Standard Assets/Scripts/FireScript1.js(40,25): UCE0001: ‘;’ expected. Insert a semicolon at the end.
3- Assets/Standard Assets/Scripts/FireScript1.js(41,19): BCE0044: expecting :, found ‘+=’.
For it, Could anybody help me with that problem?
Thanks in advance
Best Regards
Alejandro Castan