I really tried to figure this out, but I don’t understand the problem.
If I pass the names of the CollisionNodes, the event is triggered.
handler.addInPattern('cSegment-into-cSphere')
But when I try to use things like tags, nothing happens:
handler.addInPattern('cSegment-into-%(mytag)ih')
When I print a collisionEntry in the first example, it shows my into node really has a tag named “mytag”.
So what am doing wrong when constructing the string?
Here:
from panda3d.core import *
import direct.directbase.DirectStart
base.cTrav = CollisionTraverser('cTrav')
base.cTrav.showCollisions(render)
eventhandler = CollisionHandlerEvent()
eventhandler.addInPattern('%fn-into-%(mytag)ih') # eventhandler.addInPattern('%fn-into-%in') # THESE WORK
eventhandler.addOutPattern('%fn-out-%(mytag)ih') # eventhandler.addOutPattern('%fn-out-%in')
# FROM
parent = loader.loadModel('panda')
parent.reparentTo(render)
colsphere = parent.attachNewNode(CollisionNode('csphere'))
colsphere.node().addSolid(CollisionSphere(0, 0, 0, 1))
# INTO
parent2 = loader.loadModel('panda')
parent2.reparentTo(render)
parent2.setTag('mytag', 'Some value')
parent2.setX(10)
colsphere2 = parent2.attachNewNode(CollisionNode('csphere2'))
colsphere2.node().addSolid(CollisionSphere(0, 0, 0, 1))
base.accept('a', lambda: parent2.setX(parent2, -1))
def In(entry):
print entry
def Out(entry):
print entry
base.accept('csphere-into-mytag', In) # base.accept('csphere-into-csphere2', In) # THESE WORK
base.accept('csphere-out-mytag', Out) # base.accept('csphere-out-csphere2', Out)
base.cTrav.addCollider(colsphere, eventhandler)
run()
BTW, checking for tag value instead of tag name the same way works ("%(tag)it")
Cam someone please test this code?
Come on guys. I don’t want to report this as a bug without being sure.