Instead of talking about it all day, let's get the system working and talk about the code once we've finished. Having the examples on hand will help clarify how it all works.
First off, let's import the
Vec3
Panda3D class that we'll be using. Add this below the first line ofCycleClass_02.py
:from pandac.PandaModules import Vec3
To keep our
Cycle
class's__init__
method from getting too cluttered, we're going to create a new method to handle some of our set up. Right after thesetKey()
method, add a new definition that looks like the following line of code:def setupVarsNPs(self):
To give this new method some purpose right off, move these lines from the
__init__
method down into the new method we just defined:self.root = render.attachNewNode("Root") self.speed = 0 self.throttle = 0 self.maxSpeed = 200 self.accel = 25 self.handling = 20 self.cycle = loader.loadModel("../Models/Cycle.bam") self.cycle.reparentTo(render) self...