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 - creating a simple collision detection system

For this exercise, we won't be using our game. Instead, we're going to start with a blank document and make a quick little collision system to see things in action before we start on the more complicated collisions in the game.

  1. Create a blank document in Notepad++ and save it as chp06_01.py.
  2. Add this block of code to the beginning of the file:
    import direct.directbase.DirectStart
    from direct.showbase.DirectObject import DirectObject
    from pandac.PandaModules import *
    class World(DirectObject):
    def __init__(self):
    
  3. Right after that, type in these lines:
    self.colNode1 = CollisionNode("colNode1") colSphere1 = CollisionSphere(4.1,30,0,1) self.colNode1.addSolid(colSphere1) self.colNP1 = render.attachNewNode(self.colNode1) ...

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