Bullet Position of node contact

I am using bullet, and I am testing collision, and I wish to know the pos of one of the object collided:

result = world.contactTest(self.bodyNP.node())
for node in result.getContacts():
    print myFirstObject.getPos()
AttributeError: 'libpandabullet.BulletGhostNode' object has no attribute 'getPos'


AttributeError: 'libpandabullet.BulletRigidBodyNode' object has no attribute 'getPos'

I am colliding one bulletGhostNode with a bulletRigidBodyNode.

How can I retrieve position from this bulletNode?


I’m not exactly sure what your code does, but this is what I use for ‘bullet’ collision.

        entries = []
        for i in range(self.pickerCollisionHandler.getNumEntries()):
            entry = self.pickerCollisionHandler.getEntry(i)
        if(len(entries) > 0):
            entries.sort(lambda x,y: cmp(self.DistanceFromCam(x.getSurfacePoint(render)),
            point = entries[0].getSurfacePoint(render)

The important part is entry.getSurfacePoint(render). The Collision Entry objects are what contain all of the useful information about a collision.

In fact, I use bullet (the physic engine) to create node, and manage collision.
My program runs as a server, and it is about AI, and not for the player himself.

So I don’t think your solution can be applyable.

I think it must be an easier way to grab position from collision test

But thank you for your time

BulletRigidBodyNode is derived from PandaNode. You can get the position the same way as you would get it from any other node in the scene graph (e. g. a GeomNode):


Or you create a NodePath for this node:

np = NodePath(node)