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 - setting and getting PythonTags

Let's add a PythonTag to our CollisionNodes so we can print out the names of the cycles when they collide.

  1. In the setupCollisions method of our Cycle class, add the following line of code right after we create self.shieldCN:
    self.shieldCN.setPythonTag("owner", self)
    
  2. In the bump method, replace the print statement we have with the following:
    print(entry.getFromNodePath().getPythonTag("owner").name)
    print("has bumped into:")
    print(entry.getIntoNodePath().getPythonTag("owner").name)
    print("")
    
  3. Save the file as CycleClass_04.py.
  4. Modify WorldClass_03.py to import CycleClass_04.py instead of CycleClass_03.py. Then, save it as WorldClass_04.py and run it from the command prompt. Make sure to watch the command ...

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