As a summer project I have been trying to make a minecraft clone with panda3d. I got the terrain to generate with collision solids as well. However, when I try to add a player that has a collisionhandlergravity to make him fall, after a few seconds the game freezes and I have to force quit it. If i get rid of the collisionhandler, it works fine. I have checked to make sure that the collision nodes are facing the right way and are in the right position. please help.
class Avatar:
def __init__(self,position):
avatarFloorHandler = CollisionHandlerGravity()
avatarFloorHandler.setGravity(9.81+25)
avatarFloorHandler.setMaxVelocity(100)
avatarNP = render.attachNewNode("avatar")
avatarNP.setPos(position)
avatarNP.setZ(avatarNP.getZ()+.25)
avatar = loader.loadModel('smiley')
avatar.reparentTo(avatarNP)
avatarRay = avatarNP.attachNewNode(CollisionNode('avatarRay'))
avatarRay.node().addSolid(CollisionRay(0,0,1.5,0,0,-1))
avatarRay.node().setFromCollideMask(BitMask32(0x4))
avatarRay.node().setIntoCollideMask(BitMask32(0x0))
avatarFloorHandler.addCollider(avatarRay,avatarNP)
base.cTrav.addCollider(avatarRay, avatarFloorHandler)
class MyApp(ShowBase):
def generatechunk(self):
#procedural geometry stuff omitted for brevity
colnodeX = CollisionNode("cnode")
colnodeY = CollisionNode("cnode")
colnodeZ = CollisionNode("cnode")
#for every face that needs to be added:
#add the face to the geometry
colnodeZ.addSolid(CollisionPolygon(blah blah)) #to add the face to the correct collisionNode
#more omitted code
nodePath = render.attachNewNode(node)
nodePath.setCollideMask(BitMask32(0x0))
colnodeX.setIntoCollideMask(BitMask32(0x1))
colnodeY.setIntoCollideMask(BitMask32(0x2))
colnodeZ.setIntoCollideMask(BitMask32(0x4))
colnodepathX = nodePath.attachNewNode(colnodeX)
colnodepathY = nodePath.attachNewNode(colnodeY)
colnodepathZ = nodePath.attachNewNode(colnodeZ)
#The avatar is added later after many chunks have been generated.