I’ve just started building a 3d platformer using Panda. I’ve got a blender world model imported and got a set of Bullet collision objects created to match the geometry. I’ve also got a nice bullet character controller barely working. I have two issues.
First, the collision seems to be working pretty good, but every once and a while the character falls about half a unit through the ground in areas that look like they are always around where two collision triangles meet. Here is a screenshot of it happening http://i.imgur.com/uQQxs4K.png. It is literally like there are tiny ditches in the ground. I’ve checked the character’s isOnGround() method and it appears he leaves the ground for a frame every once and a while when this happens.
This is the code where I setup the collision:
self.world = BulletWorld()
self.world.setGravity(Vec3(0, 0, -9.81))
self.world.setDebugNode(debugNP.node())
self.environ = self.loader.loadModel("models/base")
self.environ.reparentTo(self.render)
self.environ.setScale(1, 1, 1)
self.environ.setPos(0, 0, 0)
self.geomCollect = self.environ.findAllMatches('**/+GeomNode')
self.col = BulletTriangleMesh()
for np in self.geomCollect:
for i in range(np.node().getNumGeoms()):
geom = np.node().getGeom(i)
self.col.addGeom(geom)
shape = BulletTriangleMeshShape(self.col, dynamic=False)
node = BulletRigidBodyNode('Base')
node.addShape(shape)
self.render.attachNewNode(node)
self.world.attachRigidBody(node)
self.taskMgr.add(self.update, 'update')
Secondly, the character controller is working fine for moving linearly, but when I set the angular movement it just responds in chunks of movement. I don’t see what is different between the two methods.
Here is the code for input:
self.accept('w', self.processInput, ['w'])
self.accept('a', self.processInput, ['a'])
self.accept('s', self.processInput, ['s'])
self.accept('d', self.processInput, ['d'])
self.accept('w-up', self.processInput, ['w-up'])
self.accept('a-up', self.processInput, ['a-up'])
self.accept('s-up', self.processInput, ['s-up'])
self.accept('d-up', self.processInput, ['d-up'])
self.accept('space', self.processInput, ['space'])
def processInput(self, key):
if key == 'w':
self.playerNP.node().setLinearMovement(Vec3(0, 10, 0), True)
elif key == 's':
self.playerNP.node().setLinearMovement(Vec3(0, -10, 0), True)
elif key == 'a':
self.playerNP.node().setAngularMovement(480)
elif key == 'd':
self.playerNP.node().setAngularMovement(-480)
elif key == 'a-up' or key == 'd-up':
self.playerNP.node().setAngularMovement(0)
elif key == 'w-up' or key == 's-up':
self.playerNP.node().setLinearMovement(Vec3(0, 0, 0), True)
elif key == 'space':
self.playerNP.node().doJump()
Any help is much appreciated. Panda has been really easy to work with so far. Just these few kinks.