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 - adding an input manager

To illustrate how this works, we're going to take the keyboard controls out of the Cycle class, put them in a new class, and give the Cycle class access to those controls.

  1. To start with, save CycleCLass_03.py as InputManagerClass_01.py. Since we're taking pretty much all of the code we need from the Cycle class, we might as well use it as a starting point.
  2. Delete the line where we import Vec3. We don't need Vec3 for this class, so we don't need to import it.
  3. Change the class definition line to reflect our new class name: InputManager:
    class InputManager(DirectObject):
    
  4. Delete the first two lines in the __init__ method. We don't need to set up any variables or NodePaths, so we don't need to call setupVarsNPs() ...

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