Is it possible to early invoke a scheduled event?

airoll

Member
Hello, I am trying to implement a temporary boost (e.g. with duration 30s) in my game. I would like to use the Scheduler.ScheduleFixed(...) method to reset the speed attribute back to the original speed after the boost expires. However, if the player dies, then I also want to reset the speed attribute.

Therefore, I am wondering, if I call Invoke() on the ScheduledEventBase that is returned by the Scheduler.ScheduleFixed(...) method, what exactly happens?
  1. Will the Action I specified in ScheduleFixed(...) execute?
  2. Will ScheduledEventBase.Active become false?
  3. Do I need to cancel the scheduled event?
  4. What happens to the ScheduledEventBase variable after the scheduled event executes. Does it become null, or just have Active = false? (Sorry this might be repeating the above questions).
 
We can write a simple test using a coroutine to test this, i.e. start a fixed schedule, then start a coroutine which will Invoke that schedule at an earlier time.

If you don't manually Cancel the schedule when Invoking it, then yes the schedule will still execute at its fixed time. Active will only become false if you manually Cancel it. Also, the ScheduledEventBase reference variable will not become null, even after Cancel.

Hope that helps
 
Top