O'Reilly logo

Panda3D 1.6 Game Engine by Dave Mathews

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - exploring task return options

We're going to modify our two tasks to take advantage of some of these other task return options. To start with, we're going to change cycleMove so that it stops after the cycle has moved a set distance. After that, we'll change debugTask to only print once every second.

  1. The first thing to do is create a variable that will store the distance the cycle has travelled, so we can make it stop once that distance is greater than a certain amount. In our __init__ method, we need to add a line to declare the variable. Put this line just before our call to taskMgr.doMethodLater in the __init__ method.
    self.cycle2.setPos(-2,15,0)
    self.distTrav = 0
    
  2. taskMgr.doMethodLater(5, self.cycleMove, "Cycle Move")Now we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required