So I have some code:
def detectShots(self, task):
if self.notifier.getNumEntries() >= 1:
self.dr = True
for i in self.notifier.getEntries():
if "zombie" in str(i):
self.zombiesHit.append(self.getZomName(i))
for zombieName in self.zombiesHit:
dst = zombieName.getDistance(self.cam)
zombieName.setPythonTag("dst", dst)
self.distanceZombies.append(dst)
lengthDst = len(self.distanceZombies)
shortestDistance = min(self.distanceZombies)
zombieNName = shortestDistance
for x in self.zombiesHit:
if x.getPythonTag("dst") == (shortestDistance):
self.zombie_shot(x.getPythonTag("HP"), x, x.getPythonTag("COLNODE"))
self.clear(self.distanceZombies)
self.clear(self.zombiesHit)
self.notifier.clearEntries
return task.cont
And when I run it (and shoot the zombie), it says:
dst = zombieName.getDistance(self.cam)
AssertionError: !is_empty() at line 1834 of panda/src/pgraph/nodePath.cxx
This means I haven’t deleted the zombie from the list yet, right? How? Clear is a method I made.
def clear(self, list):
if list:
for i in list:
list.remove(i)
Tell me if I need to clarify anything, I’m in a hurry.
Thanks a lot!