- Home /
Duplicate Question
How do I make an Ai shoot every 3 seconds?
I'm working on a game with a friend and I'm having trouble making the Ai shoot every 3 seconds.
there must be ONE THOUSAND identical questions to this. it's too much, from now on they'll just be closed
TI$$anonymous$$ERS IN UNITY .. USE "INVO$$anonymous$$E()"
ah but not everywhere says about invoke this is the 2. time I've heard about it and will start slowly looking in to invoke
thumbs up for closing and pointing the Q
Fattie is the Ambassador for Invoke and InvokeRepeating, I'm really surprised you havn't seen that before now =]
it's important to use "time" etc etc etc later in advanced program$$anonymous$$g
But for timers in Unity you simply use Invoke or InvokeRepeating
its just that simple.
It is inconceivable that you would have to f--- around with time, comparisons, loops etc in a game engine .. to make a trivial timer
The whole issue drives me freaking nuts.
Invoke( "go bonkers!", next time you see a timer question );
Answer by cdrandin · Apr 07, 2013 at 06:29 PM
Basic Timer implementation
float timer;
int waitingTime;
void Update(){
timer += Time.deltaTime;
if(timer > waitingTime){
//Action
timer = 0;
}
}
Simple and easy xD
Just to improve, in this case: int waitingTime = 3
Follow this Question
Related Questions
How Would I Change This To Read Within A Time Range? 1 Answer
turret firing delay timer? 2 Answers
How to Count quited(program off) time 1 Answer
Tell me about timing in Unity 0 Answers
Start Something on Main Scene Start Up 0 Answers