Hi,
I have loaded up this script and it says that I already have a definition for my two non update or start functions! Please help:
#pragma strict
var Damage = 100;
var MagAmmo = 20;
var CurrentAmmo = 20;
var MaxAmmo = 100;
var Range = int;
var reloadTime = int;
var Ammo : GUIText;
var Gunshot : AudioClip;
var ClipOut : AudioClip;
var Reload : AnimationClip;
var Fire : AnimationClip;
//var LookDownScope : AnimationClip;
//var ReverseLookDownScope : AnimationClip;
//var ScopedFire : AnimationClip;
//
//var Scoped=false;
//ALL COMMENTED SCRIPT IS FOR WHEN I HAVE FIXED UN-SCOPE AND SCOPE (And When I have finished debugging script as it already is
function Start (){
MagAmmo=CurrentAmmo;
}
function Update (){
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
Debug.DrawRay (transform.position, transform.forward * 100);
if(CurrentAmmo > 0) {
if (Input.GetButtonDown("Fire1")) {
Fire ();
}
}
if (Input.GetKeyDown("r")) {
Reload ();
}
if (Input.GetButtonDown("Fire2")) {
LookDownScope ();
}
}
function Fire() {
Debug.Log("Gun Fired");
CurrentAmmo=CurrentAmmo-1;
// if(Scoped == false)
// {
animation.Play(Fire.name);
// }
// if(Scoped == true)
// {
// animation.Play(ScopedFire.name);
// }
audio.PlayOneShot(Gunshot);
if (Physics.Raycast (ray, hit, 100))
{
hit.transform.SendMessage("ApplyDamage", Damage, SendMessageOptions.DontRequireReceiver);
}
}
//function LookDownScope() {
// if Scoped = false ()(
// animation.Play(LookDownScope.name);
// Scoped = true;
// }
// if Scoped = true (){
// animation.Play(ReverseLookDownScope.name);
// Scoped = false;
//}
function Reload(){
animation.Play(Reload.name);
audio.PlayOneShot(ClipOut);
yield WaitForSeconds(reloadTime);
CurrentAmmo=MagAmmo;
}
function OnGUI (){
Ammo.text = "Ammo: " + CurrentAmmo + "/" + MaxAmmo.ToString();
}