- Home /
I want to have cancelinvoke start multiple seconds arfter object becomes invisible
I have a shooting game and I want to have the enemy stop shooting multiple seconds after becoming invisible so maybe creating like a in game timer and if >5 cancel invoke and restart on visible. In simpler term I want to wait for x number of seconds before cancelling invoke.
void OnBecameVisible(){ InvokeRepeating ("CreateBullets", ShootTime, ShootTime); ShootTime = T.Next(2,4); } void OnBecameInvisible(){ CancelInvoke ("CreateBullets"); }
Answer by kevinspawner · Aug 20, 2015 at 03:16 AM
You need to use Co-routine. It has wait for seconds function.
Your answer
Follow this Question
Related Questions
How to realize accurate time counter (millisecond precision) 3 Answers
C# simple delay execution without coroutine? 2 Answers
How to work a real life timer? 2 Answers
Timer counting UP instead of DOWN 1 Answer
How to make a Time Based Score? 1 Answer