Edit 2 : Updated code, so runnable zip isn't the same as the copied section bellow (though all that has changed is that part in run_me.py)
Edit: Runnable zip with source files, sorry: https://dl.dropboxusercontent.com/u/12781104/Collisions.zip
Right now I am trying to create a small room for my character to walk around in, it works decently but will walk through walls, I am having difficulty setting up the collision logic to stop the character from walking through walls. The problem is properly creating the collision plane to line up with the walls (is there a way to do this in blender?)...
Code so far that has to do with wall collisions
[Removed imports]
....
self.cTrav = CollisionTraverser()
robotCHandler = CollisionHandlerQueue()
robotWallCHandler = CollisionHandlerPusher()
WALL_MASK=BitMask32.bit(2)
ralphStartPos = (0, 0, 0)
self.ralph = loader.loadModel("robot.x")
self.ralph.reparentTo(render)
self.ralph.setScale(1)
self.ralph.setPos(ralphStartPos)
self.ralph.setCollideMask(BitMask32.allOff())
# setup tube to suround robot
#(robot is 3 height, by 1.5, 1.5)
cTube = CollisionSphere(0, 0, 0, 3)
robotCollisionNode = self.ralph.attachNewNode(CollisionNode('robotcnode'))
robotCollisionNode.node().addSolid(cTube)
robotCollisionNode.node().setFromCollideMask(WALL_MASK)
robotCollisionNode.node().setIntoCollideMask(BitMask32.allOff())
self.environ = loader.loadModel("room2.x")
self.environ.reparentTo(render)
root = self.environ.find("**/Root")
walls = root.findAllMatches("**/Plane*")
for w in walls:
# set it to the same bitmask so the collider collides
w.node().setIntoCollideMask(WALL_MASK)
robotWallCHandler.addCollider(robotCollisionNode, self.ralph)
self.cTrav.addCollider(robotCollisionNode, robotWallCHandler)
The bottom line is what I am most confused about, how do I get the collision plane properly setup, do I just have to hard code the points or is there something easier (maybe the geom nodes?)?