CollisionHandlerGround

Since moving a character on uneven terrain is exactly what I need to accomplish, I wanted to try using this; however, I’m having trouble figuring out why it’s not actually doing anything. I assume the repositioning is supposed to be automatic every frame, but it’s not happening. I copy-pasted the code from the labyrinth sample to get the ray pointing down, then just run


self.environ.node().setIntoCollideMask(BitMask32.bit(1))

(the CollisionRay’s FromCollideMask is definitely set to 1 also). Is there a step I’m missing? Does something need to be changed in the .egg file to make it the right kind of node?

Thanks!

Well, you do have to set up the CollisionHandlerFloor to tell it which node it should reposition each frame, and then add it to the CollisionTraverser, and so on. But other than that setup work, yes, it’s automatic.

David

By this do you just mean


base.cTrav.addCollider(self.ralphGroundCol, self.cHandler)

(self.ralphGroundCol is the CollisionNode attached to the character that contains the CollisionRay)? Or is there something I have to call on the handler specifically? I didn’t see anything promising in the API.

That’s part of it. You then need to tell the floor about your moving object, just like you do with a CollisionHandlerPusher (see the manual page on Collision Handlers for more info):


self.cHandler.addCollider(self.ralphGroundCol, self.ralph)

David