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 - implementing BitMasks

Using BitMasks is actually pretty easy. This example will show us how.

  1. In the setupCollisions method of our Cycle class, add the following code right after the lines where we add our CollisionSpheres to the CollisionNode:
    self.shieldCN.setIntoCollideMask(BitMask32.bit(3))
    self.shieldCN.setFromCollideMask(BitMask32.bit(2))
    
  2. Save the file as CycleClass_02.py.
  3. Modify WorldClass_01.py to import CycleClass_02.py instead of CycleClass_01.py. Then, save it as WorldClass_02.py and run it from the command prompt. Attempt to collide the two cycles together and we'll see them pass through each other, like in the following screenshot:

What just happened?

Our cycles don't collide anymore! That's because they are set to have ...

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