collisionHandlerFloor ...

I’m having trouble with the collisionHandlerFloor(), I think i set the whole bunch up allright, but it just wont do anything…

Dont know wether it matters, but I used baked in solids in the models (polyset)

This is the code I’m using:


def loadWorld(self):
        # load models
        self.scene = loader.loadModel('models/course1/course1')
        self.scene.reparentTo(render)
        self.solids = loader.loadModel('models/course1/course1_coll')
        self.solids.reparentTo(render)
        self.player = loader.loadModel('models/carnsx/carnsx2')
        self.player.reparentTo(render)
        self.player.setScale(0.7)

        #set collision solids
        # all basic collisions are on bit 0

        # wall solids
        self.walls = self.solids.find("**/wall")
        self.walls.node().setIntoCollideMask(BitMask32.bit(0))

        self.ground = self.solids.find("**/ground")
        self.ground.node().setIntoCollideMask(BitMask32.bit(0))

        #car solids
        self.body = self.player.attachNewNode(CollisionNode('colNode'))
        self.body.node().addSolid(CollisionRay(0, 0, 0, 0, 0, -1))
        self.body.node().setIntoCollideMask( BitMask32.allOff() )
        self.body.node().setFromCollideMask( BitMask32.bit(0))

        # add collision nodes to a collision handler
        self.cTrav = CollisionTraverser()
        self.cHandler = CollisionHandlerFloor()
        self.cHandler.addCollider(self.body,self.player)
        self.cTrav.addCollider(self.body.node(), self.cHandler)
        base.cTrav = self.cTrav        

Hmm, seems ok to me too.

For debugging, you can try getting to a position where you should be detecting a collision, and running code like this:

Notify.ptr().getCategory(':collide').setSeverity(NSDebug)
base.cTrav.traverse(render)
Notify.ptr().getCategory(':collide').setSeverity(NSInfo)

The first line turns on spammy debugging output of the collision subsystem. The second line runs the traverser with this debugging output enabled. The third line returns the output to normal, so you don’t continue to get spammed.

It might shed some insight into what’s going on. If it’s not enough information, try subsituting “NSSpam” for “NSDebug” in the above to make it extra spammy.

David

Not sure if this will work but try adding the nodepath to the collision traverser instead of the node itself.

change


self.cTrav.addCollider(self.body.node(), self.cHandler)

to


self.cTrav.addCollider(self.body, self.cHandler)