Hi i’m currently working on a script for the assault rifle firerate in my game but i can’t test it properly because i get this error, but i have no idea what it means. I’m not exactly the most experienced coder.
Here’s my code… Please tell me what i’ve done wrong…
var Damage : int = 50 ;
var GunSound : AudioClip[];
var Blood : GameObject;
var Blood_splat : GameObject;
var Bullet_Hole : GameObject ;
var Ricochet : GameObject ;
var FireRate : float = 0.25 ;
var Canshoot = true ;
function Update ()
{
if (Input.GetButton("Fire1"))
{
if (Canshoot== true) ;
{
var hit : RaycastHit;
audio.clip = GunSound[Random.Range(0, GunSound.length)];
audio.Play();
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
{
hit.transform.SendMessage("ApplyDamage", Damage, SendMessageOptions.DontRequireReceiver);
if ( hit.collider.gameObject.tag == "Flesh" )
{
Instantiate(Blood, hit.point, Quaternion.identity);
Instantiate(Blood_splat, hit.point, Quaternion.identity);
}
if ( hit.collider.gameObject.tag == "World" )
{
Instantiate(Ricochet, hit.point, Quaternion.FromToRotation(Vector3.forward ,hit.normal));
Instantiate(Bullet_Hole, hit.point, Quaternion.FromToRotation(Vector3.up ,hit.normal));
}
Canshoot = false ;
}
}
if (Canshoot == false)
{
yield WaitForSeconds(FireRate);
Canshoot = true;
}
}
}