So I have a very basic script to test the increment of an integer called “wood”. I have a method that contains an if loop that increments wood by 1 if it’s less than 10. I want wood to increment every 2 seconds so I set an invoke in the Update method. The problem is, after the first two seconds, the wood is fully incremented instantly instead of over time. My script is this:
using UnityEngine;
using System.Collections;
public class AddWood : MonoBehaviour {
public int wood = 1;
void IncreaseWood() {
if (wood < 10) {
wood++;
print (wood);
}
}
void Update() {
Invoke ("IncreaseWood", 2);
}
}