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 ground collision system

This is going to be another long example, so let's pay close attention to each step and make sure we get everything right.

  1. To begin with, we're going to make some modifications to our Track class to prepare it. Open the TrackClassHero.py file in the Chapter06 folder and resave it as TrackClass_01.py.
  2. The first change to make is to remove the line that resets the track's position to 5 units lower.
  3. Once that is gone, add in these lines at the end of the class:
    self.gravity = 1
    self.groundCol = loader.loadModel("../Models/Ground.egg")
    self.groundCol.reparentTo(render)
    mask = BitMask32.range(1,3)
    mask.clearRange(2,1)
    self.groundCol.setCollideMask(mask)
    
  4. We also need an import to use BitMask. Add this ...

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