This is going to be another long example, so let's pay close attention to each step and make sure we get everything right.
To begin with, we're going to make some modifications to our
Track
class to prepare it. Open theTrackClassHero.py
file in theChapter06
folder and resave it asTrackClass_01.py
.The first change to make is to remove the line that resets the track's position to 5 units lower.
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)
We also need an import to use
BitMask
. Add this line to the very top of the file:from pandac.PandaModules import *
Resave the file again.
The rest of the changes we need to make will be in the
Cycle
class, so openCycleClass_04.py
up again.Our first addition will be to the end...