- Home /
Question by
mcgamerx19 · Aug 05, 2014 at 11:37 PM ·
functionminutes
Script to run function every X minutes?
Is there any way to run a script every X number of minutes?
For example
in 10 minutes {
animation.Play("Blank");
}
Comment
Best Answer
Answer by rutter · Aug 05, 2014 at 11:29 PM
Sounds like you want InvokeRepeating or perhaps a coroutine.
For example:
function Start() {
//10 minutes is 600 seconds
InvokeRepeating("Tick", 600, 600);
}
function Tick() {
Debug.Log("Ten minutes have passed");
}
Answer by RSteele · Aug 06, 2014 at 01:23 AM
This should work:
var PauseTime: float = 600;
private var NextTime : float = 0;
function Update () {
if (Time.time > NextTime ) {
NextTime = Time.time + PauseTime;
animation.Play("Blank");
}
}
Your answer
Follow this Question
Related Questions
How to call a function on a prefab script 2 Answers
How to call a function from a script in another scene 5 Answers
Calling a Function from other script ( C# ) 1 Answer
How to turn on and turn off function with button. 1 Answer
how would i cause the function to wait until it stops to function again? 1 Answer