So i have a script that reduces ammo and readds ammo, but i want so it takes some time after u have shooted to be able to shoot again and my script doesnt work? (ShotScar, ReloadScar is my animations)
Please Help!
~carlqwe
Code (js):
#pragma strict
var ammo : float;
function Start ()
{
ammo = 30;
}
function Update ()
{
if(Input.GetKeyDown(KeyCode.R))
{
if(ammo < 30)
{
SendMessage("ReloadScar", SendMessageOptions.DontRequireReceiver);
ammo = 30;
}
}
if(Input.GetMouseButtonDown(0))
{
if(ammo > 0)
{
SendMessage("ShotScar", SendMessageOptions.DontRequireReceiver);
ShotSL ();
}
if(ammo < 0)
{
ammo = 0;
}
}
if(ammo > 30)
{
ammo = 30;
}
}
function OnGUI ()
{
GUI.Label(Rect(60,15,25,25),ammo.ToString());
}
function ShotSL ()
{
ammo--;
yield WaitForSeconds(2);
}