Bullet get the name of collision objects

I am trying to implement a gun using Bullet Physics and i need to detect if the bullets collide with another player so that I can decrease the other players health.

I can get the BulletRigidBodyNode’s that a bullet collides with as follows:

results = self.world.contactTest(projectile.node())
for contact in results.getContacts():
     print contact.getNode0()
     print contact.getNode1()

When a bullet rigid body is created it can be assigned a name:

self.thisPlayer = BulletRigidBodyNode('Player')

Is there a way of getting the name from a BulletRigidBodyNode ?

BulletRigidBodyNode derives from PandaNode, and therefor you can use all the features a PandaNode provides, e. g. set/get a name or assign/retrieve strings as (C++) tags or arbitray python objects as pypthon tags.

e.g.:

node = BulletRigidBodyNode('Player')
print(node.hasName()) # True
print(node.getName()) # 'Player'

np = NodePath(node)
print(np.getName()) # 'Player'

node.setPythonTag('hitpoints', 400)
print(node.getPythonTag('hitpoints')) # 400

Thanks enn0x that’s exactly what I needed! :smiley: