Hi for all
I have collision detection in my game. I have 3 plates. Two of them have this bitmask set of from and into mask:
self.Prato1.SetFromMask(-1)
self.Prato1.SetIntoMask(1)
self.Prato2.SetFromMask(-1)
self.Prato2.SetIntoMask(1)
These function are described below:
def SetFromMask(self, IDMask):
if(IDMask == -1):
self.PlateCollision.setFromCollideMask(BitMask32.allOff())
else:
self.PlateCollision.setFromCollideMask(BitMask32.bit(IDMask))
def SetIntoMask(self, IDMask):
if(IDMask == -1):
self.PlateCollision.setIntoCollideMask(BitMask32.allOff())
else:
self.PlateCollision.setIntoCollideMask(BitMask32.bit(IDMask))
And this is the way that I insert the collision type in them:
bounds = self.PlateModel.getChild(0).getBounds()
self.PlateCollision = CollisionNode('Plate')
#CollisionPolygon(Point3(0, 0, 0), Point3(0, 0, 1), Point3(0, 1, 1), Point3(0, 1, 0))
self.PlateCollision.addSolid(CollisionSphere(bounds.getCenter(), bounds.getRadius()*0.5))
The two plates uses this function to print their ID
def HandleCollision(self, entry):
print str(self.IDObj)
the third, that is the collider have this definition
BeeNodePusher = CollisionNode('BeePusher')
#CollisionSphere(bounds.getCenter(), bounds.getRadius()*0.5)
BeeNodePusher.addSolid(CollisionSphere(bounds.getCenter(), bounds.getRadius()*0.5))
BeeNodePusher.setFromCollideMask(BitMask32.bit(1))
BeeNodePusher.setIntoCollideMask(BitMask32.allOff())
self.BeeNodePathPusher = self.Bee.attachNewNode(BeeNodePusher)
self.Collision.CollisionPusher.addCollider(self.BeeNodePathPusher, self.Bee)
BeeNodeCollision = CollisionNode('Bee')
self.Collision.CollTraverser.addCollider(self.BeeNodePathPusher, self.Collision.CollisionPusher)
The collision works very fine. But now I explain my problem. If I collide in any of the objects the ID’s of both are printed. What I want to know is:
How can I recognize two or more objects from the same type? Each of them are instantiated separately, so why this behavior is occuring?
Thanks for the support again