I’m having a weird issue with my collisions and I hope you fortunately can help me…
In my my game, I have a (human) model where each geometry (foot, leg, arm, etc) has an unique collision shape associated to it (in this case, a BulletTriangleMeshShape). This model is placed in an infinite ground (in this case, a BulletPlaneShape). The problem: when the game starts the model pass through the floor instead of standing on the floor. Gravity is ON.
PS: Unfortunately BulletConvexHullShape not fit my purposes once I need know exact points of collisions (I make simulation of touch with this feature).
def create_ground(self): # Ground shape = BulletPlaneShape((0, 0, 1), 3) ground_node = BulletRigidBodyNode("ground") ground_node.addShape(shape) ground_node.setMass(10000) self.physics_manager.attachRigidBody(ground_node) ground_np = self.render.attachNewNode(ground_node) return ground_np def create_avatar(self, model_file, name, initial_pos, total_mass, objects_props): ## Load the 3d model file using the asset folder relative path avatar_np = self.loader.loadModel(Filename.from_os_specific(model_file)) avatar_np.setName(name) avatar_np.setPos(initial_pos) avatar_np.setP(90) # Fix C4D rotation issue ## Eliminate any transform with scale and rotate to a shape: ## ## Scale is bad when it comes to physics. Bullet does support scale, but only to a limited degree and at the ## cost of performance. So get rid of any scale within your modeling application (Cinema4D, Blender, Maya, ## etc) - look at the exported egg -> does it have transforms with scale? ## If this is the issue, I suggest you simply make sure that every object in your modeling application has ## the center of mass as origin, and has no rotations and no scale on it. avatar_np.flattenLight() ## Parse Avatar file to check inconsistences for object in objects_props: object_np = avatar_np.find("**/" + objects_props['name']) if not object_np.isEmpty(): if type(object_np.node()) == GeomNode: ## Create the rigid body body_node = BulletRigidBodyNode(objects_props['name']) ## If object has mass create a physical shape for it perc_mass = float(objects_props['perc_mass']) if perc_mass > 0: ## Create the shape used for collisions mesh = BulletTriangleMesh() for geom in object_np.node().getGeoms(): mesh.addGeom(geom) shape = BulletTriangleMeshShape(mesh, dynamic=False) body_node.addShape(shape) ## Get the percent of mass from part relative to the avatar and calculate its absolute mass mass = total_mass * perc_mass body_node.setMass(mass) body_node.setDeactivationEnabled(False) self.physics_manager.attachRigidBody(body_node) else: print("WARNING: The object '" + objects_props['name'] + "' has no mass defined.") body_np = avatar_np.attachNewNode(body_node) body_np.setPosHpr(object_np.getPos(), object_np.getHpr()) # Attach the geom node to rigid body object_np.reparentTo(body_np) object_np.setPosHpr((0, 0, 0), (0, 0, 0)) else: print("WARNING: The object '" + objects_props['name'] + "' specified in 'objects' list not exists.")