Intervals are very similar to tasks in that they are used to perform an action over time.
They are also similar to animations because they can be controlled with simple start, loop, and stop methods just like animations.
Unlike tasks, Intervals automatically take into account the passage of time instead of executing on each frame, or waiting an amount of time to then execute in a single frame. They also use a finite duration of time, and stop automatically when that amount of time has passed.
To use Intervals, we need to import them with this import line:
from direct.interval.IntervalGlobal import *
Then, we can create Intervals by calling the constructor and giving it the necessary arguments: ...