- Home /
Cant find my error in JavaScript?
Hey everyone, im following a guide through youtube that is showing me lots about unity and java scripting, but ive run into a problem, first of all does mono-develop show you where your error is? i get an error saying was expecting ), instead found 'fire'. Can anyone find the mistake? thankyou. The script is for reloading with guns for an fps.
var Bullet : Rigidbody; var Spawn : Transform; var BulletSpeed : float = 1000; var ReloadTime : float = 2; var AmmoInMag : float = 30;
static var AmmoLeft : float; private var CanFire = true;
function Start () { AmmoLeft = AmmoInMag; }
function Update () { if(Input.GetButtonDown("Fire1")){ if(AmmoLeft > 0){ BroadcastMessage("FireAnim"); Fire(); } }
if(AmmoLeft == 0)
{
Reload();
}
if(AmmoLeft < 0){
AmmoLeft = 0;
}
function Fire(){ if(CanFire == true){ var bullet1 : Rigidbody = Instantiate(Bullet,Spawn.position,Spawn.rotation); bullet1.AddForce(transform.forward *BulletSpeed); AmmoLeft .= 1;
audio.Play(); }
function Reload(){ CanFire = false; BroadcastMessage("ReloadAnim"); yield WaitForSeconds(ReloadTime); CanFire= true;
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Error CS1502 Help! 1 Answer
Need Help | Door Opening Script Error 1 Answer
Error Code BCE0019 1 Answer
Wierd error messages concerning audio play and pause? 1 Answer