Timers and Timing

Much like our animation framework, there is a version of timerFired in Panda3D. It's called the task manager.

You need to import:

from direct.task.Task import Task

Now, you can use the task manager. There is a method called add that you call on the Task Manager:

taskMgr.add(self.move, "move")

These lines of code tell the task manager to call the method self.move every small amount of time (built-in).

The last argument is a label - make sure the label is something unique, and it's just for the task manager to organize itself.

You can also use the method doMethodLater like

taskMgr.doMethodLater(time, self.move, "move")

which allows you to control how often the method is called.

results matching ""

    No results matching ""