Last updated
Last updated
The Scheduler is an important component in FP Motion; its main function is to allow developers to run certain motions with delays, loops, or other 'playback' functionality.
Some components that use the Scheduler are:
Land Component. This component uses the Scheduler to apply a force for a couple of seconds once the player lands. This provides a much nicer effect that applying it all at once.
Non-Monobehaviour Updates. Some components use the Scheduler as a replacement for being a MonoBehaviour
. The way this works is by subscribing to it, and the Scheduler invokes the subscribed function on an Update.
Complex Motions. We will include more complex motions like reloading in the asset, the way we will make them work is by relying on the Scheduler’s capabilities.
Usually, we will place this component on the player, or on a Manager object, and leave it there for other components to use during play mode.
The inner workings of this component are fairly simple, it receives requests for things that need scheduling, whether they be on an update function, or after a certain period, and fulfills those requests.
FP Motion 1.0, only has one method of scheduling. Version 2.0 will contain more!
The way to schedule something to happen is by using the TickSchedule method, which looks the following way:
There is a variation to this function that allows you to schedule a method when the duration elapses.
All this function does is take a method, and schedule it to get invoked inside an Update, FixedUpdate, or whatever the developer picks as a scheduledTime.
The duration determines the time that it will stay scheduled, when that timer ends, the method is removed from that scheduling and stops being invoked.
To use the Scheduler there is a need to first access it. We made this simple by making it a Singleton.
To access the instance of this component:
Now the TickSchedule function can schedule methods, a good example would be:
A good example of how scheduling can produce cool results is the Land component.
Usually, we will place this component on the player, or on a Manager object, and leave it there for other components to access during play mode.