Hi im a beginner to using panda,
What im trying to do is to get a text label to update when my car drives into a certain area.
Heres a snippet of my code:
def checkpoint(self):
self.cp = self.loader.loadModel("models/box")
self.cp.reparentTo(render)
self.cp.setPos((random.randint(-80, 80)), (random.randint(-80, 80)), -1) # The map of the game is roughly 80x80
cpLabel = DirectLabel(pos=(-0.9, 0, -0.8))
cpLabel.reparentTo(aspect2d)
cpLabel.setScale(0.1)
counter = 0
cpLabel['text'] = "Checkpoint: 0/5"
def cpTask(self, task, counter, cpLabel):
if counter < 5:
if (self.cp.getY() + 10) > self.PlayerNP.getY() > (self.cp.getY() - 10) and \
(self.cp.getX() + 10) > self.PlayerNP.getX() > (self.cp.getX() - 10):
counter = counter + 1
cpLabel['text'] = "Checkpoint: " + str(counter) + "/5"
return counter, cpLabel
return Task.cont
else:
return Task.done
taskMgr.add(cpTask, 'cpTask', extraArgs=[self,counter, cpLabel], appendTask=True)
If you could help me get it working that would be much appreciated.