hi im tring to make a game but this scrpt isnt working its ment to be a gather over time recorse script so i gets ammo every 5 seconds then another piece till it gets to max but it desnt collect unless its in the update but i cant use the wait for seconds in update how can i fix
public int AmmoRec = 0;
public int MaxAmmoRec = 500;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Add ();
}
IEnumerator Add(){
if (AmmoRec < MaxAmmoRec) {
yield return new WaitForSeconds (5.0f);
AmmoRec ++ ;
} else if (AmmoRec == MaxAmmoRec) {
AmmoRec = MaxAmmoRec;
}
Debug.Log (AmmoRec);
}