Having troubles with Collisions

Hey all,

For some reason I am seeing the collisions happen with the 'showcollisions, but I don’t get any entries printed, does someone have an idea why? BTW: p and s are classes defined in an other file.


  self.cTrav = CollisionTraverser()
  self.rightlegHandler = CollisionHandlerQueue()
  self.cTrav.addCollider(s.rightlegColNp, self.rightlegHandler)
  base.cTrav = self.cTrav
  entries = []
  for i in range(self.rightlegHandler.getNumEntries()): 
     entry = self.rightlegHandler.getEntry(i) 
     print entry

The collisions are detected (and the collision queue filled up with entries) at the time base.cTrav.traverse(render) is called. This happens in a separate task. So if you are checking the collision queue immediately after adding the handler, of course it hasn’t run the collision traverser yet!

One easy solution is to call cTrav.traverse(render) yourself. In this case, you won’t need to assign your cTrav to base.cTrav, since you don’t need the traverser to be run twice.


thanks, that was helpfull :slight_smile: