I have a script which has to be executed every 2 seconds. Is there any way to do it on Unity itself or do I have to use a timer inside the script? If I have to use a timer on the script, could please post an example to use Timer?
using UnityEngine;
class Foo : MonoBehaviour {
void Start () {
// Do you stuff
Invoke ("Start", 2);
}
}
There are many other ways using IEnumerators or checking for a timer float in update etc. This is the easiest way.
Thank you both, finally I used invokeRepeating.