I went through a lot of trouble to get the camera and the player to collide with the wall properly, and now that it works, the player can just slip through the wall if I run up against it long enough. Any ideas how to prevent something like this from happening? My code is horrible at this point since I barely got it together and working, so I made an even simpler version that pretty much does the same thing:
self.cTrav.traverse(render)
entries = []
for i in range(self.playerGroundHandler.getNumEntries()):
entry = self.playerGroundHandler.getEntry(i)
entries.append(entry)
entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(),
x.getSurfacePoint(render).getZ()))
if (len(entries)>0) and (entries[0].getIntoNode().getName() == "terrain"):
h = entries[0].getSurfacePoint(render).getZ()
self.c_node.setZ(h)
if not self.jump:
self.player.setZ(h)
else:
self.c_node.setPos(startpos)
if not self.jump:
self.player.setPos(startpos)
entries = []
for i in range(self.camGroundHandler.getNumEntries()):
entry = self.camGroundHandler.getEntry(i)
entries.append(entry)
entries.sort(lambda x,y: cmp(y.getSurfacePoint(render).getZ(),
x.getSurfacePoint(render).getZ()))
if (len(entries)>0) and (entries[0].getIntoNode().getName() == "terrain"):
h = entries[0].getSurfacePoint(render).getZ()
self.c_node.setZ(h)
if not self.jump:
self.c_node.setZ(h)
else:
self.c_node.setPos(startpos)
if not self.jump:
self.c_node.setPos(startpos)