This is the error message I got when I ran my code. I just want to make a simple collision detection via Panda’s collision traverser. I defined my collision solid in MAYA, then add tags to those parts. The following is the part of my code, which is based on the CollisionDetection sample:
# Load the box and place it in the scene, also loads its wall and ground
# collision solid
self.box = loader.loadModel("Models/Box")
self.box.reparentTo(render)
# The wall
self.walls = self.box.find("**/wall_Coll")
self.walls.node().setIntoCollideMask(BitMask32.bit(0))
self.walls.show()
# The ground
self.boxGround = self.box.find("**/ground_Coll")
self.boxGround.node().setIntoCollideMask(BitMask32.bit(1))
self.boxGround.show()
# Load the car and its collision solid
self.carRoot = render.attachNewNode("carRoot")
self.car = loader.loadModel("Models/Car")
self.car.reparentTo(self.carRoot)
# Car collision solid
self.car_coll = self.car.find("**/Car_Coll")
self.car_coll.node().setFromCollideMask(BitMask32.bit(0))
self.car_coll.node().setIntoCollideMask(BitMask32.allOff())
self.car_coll.show()
self.cTrav = CollisionTraverser()
self.cHandler = CollisionHandlerQueue()
ase.cTrav = self.cTrav
taskMgr.add(self.watcher, "watcher")
def watcher(self, task):
dt = globalClock.getDt()
for i in range(self.cHandler.getNumEntries()):
entry = self.cHandler.getEntry(i)
print "ENTRY: ", entry
name = entry.getIntoNode().getName()
if name == "wall_Coll": self.wallCollideHandler(entry)
However, when I drive the car into the wall, it doesn’t print any entry information in the console. It means that the traverser does not detect any collision. But how does the error come about?
Any suggestion will be appreciated! Thanks!