- Home /
Unity compiler throwing fake errors? Something wrong with this script.
See for yourselves, tell me if you see something wrong here. This is driving me crazy for two days!
var bulletPrefab : Rigidbody;
var initialForce : float = 200.0;
var Spawnpoint : Transform;
var Gunsmoke : Transform;
var Firerate : float = 1.0;
var NextShot : float = Firerate;
var CanFire : boolean = true;
function Update() {
if (Input.GetButtonDown ("Fire1")) {
if (CanFire == true) {
Fire ();
CanFire = false;
NextShot = 0;
}
}
if (NextShot <== Firerate) {
Firerate + NextShot * Time.deltaTime;
}
if (NextShot >== Firerate {
CanFire = true;
}
}
function Fire() {
if (Input.GetButtonDown ("Fire1")) {
var bulletClone : Rigidbody;
bulletClone = Instantiate( bulletPrefab, Spawnpoint.position, Spawnpoint.rotation );
Instantiate(Gunsmoke, Spawnpoint.position, Spawnpoint.rotation);
bulletClone.AddForce( bulletClone.transform.forward * initialForce, ForceMode.Force );
}
}
Answer by BiG · Nov 09, 2012 at 11:19 AM
if (NextShot <== Firerate) {
and
Firerate + NextShot * Time.deltaTime;
and
if (NextShot >== Firerate {
are obviously wrong.
Answer by thecoolracer · Nov 09, 2012 at 11:53 AM
Can you help me fix it then? I am new to this coding thing.
"<=" ins$$anonymous$$d of "<==". "Firerate + NextShot * Time.deltaTime;" is an incorrect instruction because you have not an assignment. And finally you missed a closed bracket in the last line reported by me.
Please, use comments next time to add requests like this.
Answer by thecoolracer · Nov 09, 2012 at 01:20 PM
I fixed majority of the problems, now I cant seem to find why it says this - (20,20): BCE0043: Unexpected token: .. Line 20 is - var.Firerate + var.NextShot * Time.deltaTime;