Error with collisiontraverser

Hey, I have a little program like roaming ralph, just better. Now I added this piece:

        self.picker = CollisionTraverser()
        self.pq     = CollisionHandlerQueue()     
        self.pickerNode = CollisionNode('mouseRay')
        self.pickerNP = camera.attachNewNode(self.pickerNode)
        self.pickerNode.setFromCollideMask(BitMask32.bit(1))
        self.pickerRay = CollisionRay()
        self.pickerNode.addSolid(self.pickerRay) 
        self.picker.addCollider(self.pickerNP, self.pq)

But now I get this error:

DirectStart: Starting the game.
Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
:collide(error): Invalid attempt to detect collision from CollisionRay into Coll
isionRay!

This means that a CollisionRay object attempted to test for an
intersection into a CollisionRay object.  This intersection
test has not yet been defined; it is possible the CollisionRay
object is not intended to be collidable.  Consider calling
set_into_collide_mask(0) on the CollisionRay object, or
set_from_collide_mask(0) on the CollisionRay object.

Why? I have another collision thing in my code to set the height of my char on the world. Why do i get that error?

You should set the into-mask of the ray to 0.

You mean like this:

self.pickerNode.setFromCollideMask(BitMask32.bit(0))

It wont help…

BitMask32.bit(0) is 1, not 0. You’re looking for BitMask32.allOff().

And I said the “into” mask, not the “from” mask. You called setFromCollideMask, you should call setIntoCollideMask again.

I want a function that returns me the object that is under my mouse like in chessboard. I tried to copy and paste that code in my program, but it didnt work. And when I set that into mask to allOff:

        self.picker = CollisionTraverser()            #Make a traverser
        self.pickerRay = CollisionRay()
        self.pq     = CollisionHandlerQueue()         #Make a handler
        #Make a collision node for our picker ray
        self.pickerNode = CollisionNode('mouseRay')
        #Attach that node to the camera since the ray will need to be positioned
        #relative to it
        self.pickerNP = camera.attachNewNode(self.pickerNode)
        #Everything to be picked will use bit 1. This way if we were doing other
        #collision we could seperate it
        #self.pickerNode.setFromCollideMask(BitMask32.bit(1)) ###1
                       #Make our ray
        self.pickerNode.setIntoCollideMask(BitMask32.allOff())
        self.pickerNode.addSolid(self.pickerRay)      #Add it to the collision node
        #Register the ray as something that can cause collisions
        self.picker.addCollider(self.pickerNP, self.pq)

It wont work either

    def getMouseOver(self):
        #return
        if base.mouseWatcherNode.hasMouse():
            mpos = base.mouseWatcherNode.getMouse()
            self.pickerRay.setFromLens(base.camNode, mpos.getX(), mpos.getY())
            print self.pq.getNumEntries()
            if self.pq.getNumEntries() > 0:
                #if we have hit something, sort the hits so that the closest
                #is first, and highlight that node
                self.pq.sortEntries()
                i = self.pq.getEntry(0)
                print i, type(i)
                return i

pq getnumentries is always 0.

did you remember to “setIntoCollideMask(BitMask32(1))”
on the object you are trying to pick? there are a few reasons why this would happen but this is th emost common.

What do you mean with the object i want to pick? Wich is it?