How do you repeatedly check an if statement every second.
i am making a fps and am trying to make it so when you run out of ammo (currentClip = = 0) then i want “theDamage” to be set to zero. It works the only problem is that when i run out of ammo, once, then i reload and “theDamage” stays on zero but my “currentClip” goes back to 75. I want to make it so it checks the function every second to see if the (currentAmmo) is equal to zero. Thx in advance ![]()
Her is my code…
function Update ()
{
if (currentClip == 0)
{
theDamage = 0;
}
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay (Vector3(Screen.width0.5, Screen.height0.5,0));
if (Input.GetButton("Fire1") && currentClip >= 1 && !reloading)
{
if (Physics.Raycast (ray, hit, 20000))
{
hit.transform.SendMessage("ApplyDamage", theDamage, SendMessageOptions.DontRequireReceiver);
}
}
}