0xNull 0 Posted January 27, 2018 How to create simple timer? For example, after which will spawned the car? Share this post Link to post Share on other sites
JackRabbott 1 Posted April 6, 2018 The first response to this thread shows how to create a simple timer. 1 Share this post Link to post Share on other sites
Chris0x 0 Posted May 19, 2018 If you want to create a timer lets say which spawns a vehicle after 3 seconds this is the way to go. setTimeout(() => { //spawn vehicle here }, 3000); Share this post Link to post Share on other sites
LeozinH1 1 Posted May 19, 2018 (edited) let myTimer = null; myTimer = setInterval(() => { // Spawn Vehicle clearInterval(myTimer); myTimer = null; }, 3000); This should work, after 3 seconds, it performs the function and clears the range (runs only once) Edited May 21, 2018 by LeozinH1 Share this post Link to post Share on other sites
Chris0x 0 Posted May 21, 2018 Am 19.5.2018 um 22:10 schrieb LeozinH1: let myTimer = null; myTimer = setInterval(() => { // Spawn Vehicle clearInterval(myTimer); myTimer = null; }, 3000); This should work, after 3 seconds, it performs the function and clears the range (runs only once) No need for an interval, just use the timeout function Share this post Link to post Share on other sites
LeozinH1 1 Posted May 21, 2018 5 hours ago, Chris0x said: No need for an interval, just use the timeout function It is true. I thought the settimeout was looping. I've never tried to use it Share this post Link to post Share on other sites