How do i get collision message in bullet world

I am confused that how shall I get collide messages such as “Cube1 collide with Cube2” or store in a boolean cube1_collide_with_cube2 in BulletWorld. I’ve no idea 'cos it’s not like collides in normal Panda, I don’t know if it will use Bitmask or something like travaser. Please help, thx!!

Codes at here:

#here creates the volleyball court
self.feild = loader.loadModel(f"{MODEL_PATH_PREFIX}court/court.egg")
mesh = BulletTriangleMesh()
for geom_np in self.feild.findAllMatches('**/+GeomNode'):
	geom_node = geom_np.node()
	ts = geom_node.getTransform()
	for geom in geom_node.getGeoms():
		mesh.addGeom(geom, True, ts)
shape = BulletTriangleMeshShape(mesh, dynamic = False)
self.floor = self.worldNP.attachNewNode(BulletRigidBodyNode('court'))
self.floor.node().addShape(shape)
self.floor.setPos(0, 0, 0)
self.floor_bitmask = BitMask32.allOn()
self.floor.setCollideMask(self.floor_bitmask)
self.world.attachRigidBody(self.floor.node())
self.feild.reparentTo(self.floor)
self.feild.setScale(39.4, 39.4, 39.4)
self.feild.setPos(-0.16, 175.7, 270)
#here creates the character
self.gawgura = loader.loadModel(f"{MODEL_PATH_PREFIX}gawgura/gawgura.egg")
shape = BulletCapsuleShape(0.3, 1.7, True)
self.gawgura_entity = self.worldNP.attachNewNode(BulletRigidBodyNode('gawgura'))
self.gawgura_entity.node().addShape(shape)
self.gawgura_entity.node().setMass(1)
self.gawgura_entity.setPos(100, 0, 70)
self.gawgura_entity.setHpr(0, 90, 0)
self.gawgura_entity.setScale(35,35,35)
self.gawgura_bitmask = BitMask32.allOn()
self.gawgura_entity.setCollideMask(self.gawgura_bitmask)
self.world.attachRigidBody(self.gawgura_entity.node())
self.gawgura.reparentTo(self.gawgura_entity)
self.gawgura.setScale(1, 1, 1)
self.gawgura.setHpr(0, -90, 0)
self.gawgura.setPos(0, -1, 0)

When the character drop down to the court, it do stop and keep static, but I have no idea how can I get the message “The character has touched the floor”.
thx for advance

The answer, in short, is that you don’t: Bullet doesn’t have this functionality, as far as I know.

Instead, what you can do is run some tests of your own–what are referred to as “queries”. In short, in your own code you test those objects that you want to see tested.

You can indeed use bit-masks, and the Bullet integration further allows for group-based testing.

See the manual, here:
https://docs.panda3d.org/1.10/python/programming/physics/bullet/queries

Ok, I got it. I will try it now!!

May I ask that if I can attend any exist project to learn, I am now a high school student

1 Like

Hmm… I’m not sure that it’s what you’re looking for (and forgive me if I’m already recommended it–I lose track of to whom I’ve linked it!), but I do have a “beginner’s tutorial” available. It doesn’t cover Bullet, but it does take one through the making of an entire–if small–game, all the way up to building a distributable.

If you’re interested, you should find it here:

However, if you are looking for an active, ongoing project, then I don’t know–perhaps someone else will have a recommendation or offer!

1 Like

Thanks for the advice, I will first learn through this tutorial and then find some projects later then!!!

Thank you ~@V@~

1 Like