Invoke is not like real time
Hi eveyone,
I use Invoke Method but it isn't like real time.
I used this code:
void Update () {
Invoke("Create", 5f);
}
void Create()
{
Instantiate(cube, new Vector3(-9.84f, 6.882f, 13.994f), Quaternion.identity);
}
But delay time isn't 5 seconds. It's like 1 milliSeconds. Why? I need 5 seconds delay.
What kind of behaviour are you trying to get? This code waits for 5 seconds and then creates about 60 cubes every second.
Answer by NoseKills · Mar 09, 2016 at 02:33 PM
If you say 'do something after 5 seconds' but say it 60 times every second (in Update), then after 5 seconds you will do that thing 60 times every second.
You could call InvokeRepeating once
void Start() {
InvokeRepeating("Create", 5f, 5f);
}
Answer by Gressx · Mar 14, 2016 at 06:26 AM
Yes it's sensible but it doesn't work :/
InvokeRepeating("Cube", 5f, 20f);
Your answer
Follow this Question
Related Questions
Time delay enemy respawn 3 Answers
Delay in time 0 Answers
Oncollisionenter and time,OnCollisonEnter and time. 0 Answers
Hide (not delete) text after given time..? 1 Answer
Mining in RTS 0 Answers