Maris Posted August 18, 2014 Share Posted August 18, 2014 Is it right?local function UpdateMe(inst) -- Do something -- ... inst:DoTaskInTime(1, function() UpdateMe(inst) end)end Link to comment https://forums.kleientertainment.com/forums/topic/39451-ontimer-function-for-prefab/ Share on other sites More sharing options...
plaidman Posted August 18, 2014 Share Posted August 18, 2014 It looks like you're trying to set up a task to run every 1 second, right? Your above code will work perfectly, but there's a more direct way to set that up:inst:DoPeriodicTask(1, function(inst) -- Do something -- ...end)The DoTaskInTime function is appropriate if you want to do something once but delay it for a period of time.DoPeriodicTask will do the task with the delay repeatedly until you cancel that task. You can store an instance of the Task like so:inst.somethingTask = inst:DoPeriodicTask(1, function(inst) -- Do something -- ...end)Then when you want to cancel the task, you can do:inst.somethingTask:Cancel() Link to comment https://forums.kleientertainment.com/forums/topic/39451-ontimer-function-for-prefab/#findComment-523938 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now