Collision woes

I can’t seem to get collisions to happen. I’ve followed the tutorials and example source code as closely as I thought possible, yet something still isn’t right. When the program runs, you can clearly see that the objects are colliding.

I apologize for posting so much code. I wouldn’t ask here if I didn’t feel like I’ve given it my honest best. I’ve spent two hours trying to figure this out on my own.



# Here's code to set up the pong paddle. I'm using a sphere for now
# just to get collision working. Then I'll figure out how to make a box
    x = self.actor.getX()
    y = self.actor.getY()
    z = self.actor.getZ()        
    self.colNode = CollisionNode("player1")
    self.colNode.addSolid(CollisionSphere(x, y, z, 1.5))
    self.colNodePath = self.actor.attachNewNode(self.colNode)
    self.colNodePath.show()
     
    self.colNode.setIntoCollideMask(BitMask32.allOff())
    self.colNode.setFromCollideMask(BitMask32.bit(0))

# Here's the code setting up the ball
    x = self.actor.getX()
    y = self.actor.getY()
    z = self.actor.getZ()        
    self.colNode = CollisionNode("ball")
    self.colNode.addSolid(CollisionSphere(x, y, z, 30.0))
    self.colNodePath = self.actor.attachNewNode(self.colNode)
    self.colNodePath.show()

    self.colNode.setFromCollideMask(BitMask32.allOff())
    self.colNode.setIntoCollideMask(BitMask32.bit(0))

# And here's setting up the traversers and what-not
    self.handler = CollisionHandlerQueue()
    self.traverser = CollisionTraverser("mainTraverser")
    self.traverser.addCollider(self.ball.colNodePath, self.handler)
    self.traverser.addCollider(self.player1.colNodePath, self.handler)
    self.traverser.showCollisions(camera)

# And finally here's the loop that exists within the main task, but
# it never actually makes it into the loop
    for c in range(self.handler.getNumEntries()):
        entry = self.handler.getEntry(c)
        name = entry.getIntoNode().getName()
        print name

UPDATE
I figured this out on my own. I didn’t actually tell the engine to check for collisions, and my setIntoCollisionMask/setFromCollisionMask functions were reversed.

I left the thread up for others if the encounter a similar problem to mine.



# And here's setting up the traversers and what-not
    self.handler = CollisionHandlerQueue()
    self.traverser = CollisionTraverser("mainTraverser")
    self.traverser.addCollider(self.ball.colNodePath, self.handler)
    self.traverser.addCollider(self.player1.colNodePath, self.handler)
    self.traverser.showCollisions(camera) 

    # HERE: Forgot to add this line
    base.cTrav = self.traverser